|
You don't talk about what happens if the file contains multiple lines. How is the resultant file displayed then.
However, can you specify what is the real problem. Here is the algo:
1> read from 1st file
2> read from 2nd file
3> concatenate the data and write it in one go or write it one at a time as soon as you get it [for this use seek()]
4> Close files.
I hope I understood you correctly.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
yes i have understood that..now what happens when u have multiple lines??
first file:
12.345 13.546 45.65 ...n
and the second file
34.56 75.35 78.35.... n
in this the its not text. its values. how can i merge it?? the same way u told me?
|
|
|
|
|
Chandrasekharanp wrote: in this the its not text. its values.
Actually it IS text. You can read the values, so it means that it is text.
Chandrasekharanp wrote: how can i merge it??
That really depends a lot on how you want to merge them. Do you need to sort the values while merging, or appending the second file to the first one is good enough ?
|
|
|
|
|
adding the second file to the first one is fine with me.. there is no need of sorting the values.
|
|
|
|
|
will this work for you?<br />
FILE *fp1,*fp2;<br />
fp1=fopen(mergedfile,"wb");<br />
fp2=fopen(file1,"rb");<br />
while(1)<br />
{<br />
fread(&data,1,1,fp2);<br />
if(feof(fp2))<br />
break;<br />
fwrite(&data,1,1,fp1);<br />
}<br />
fclose(fp2);<br />
fp2=fopen(file2,"rb");<br />
while(1)<br />
{<br />
fread(&data,1,1,fp2);<br />
if(feof(fp2))<br />
break;<br />
fwrite(&data,1,1,fp1);<br />
}<br />
fclose(fp2);<br />
fclose(fp1);
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Hi Everyone,
i am creating tables in Microsoft Access database.i want to use this database into my program. So how shall i connect database into my program.
Please Help me out wt is the procedure.
Thanks in Advance,
savitri.
|
|
|
|
|
Use CDaoDatabase class of MFC.
|
|
|
|
|
|
|
See if this example helps.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
here is an example for open and read a database *.mdb. Hope is helpful...
CString File = "database.mdb";
COleVariant var;
CDaoDatabase *db = null;
CDaoTableDef *TabDef = null;
CDaoRecordset *rec = null;
try
{
db = new CDaoDatabase(NULL);
db->Open(File, FALSE, FALSE, _T(""));
TabDef = new CDaoTableDef(db);
TabDef->Open("TABELLA1");
rec = new CDaoRecordset(db);
rec->Open(TabDef, dbOpenTable, 0);
rec->MoveFirst();
while( !rec->IsEOF() )
{
rec->GetFieldValue("CAMPO1", var);
rec->MoveNext();
}
rec ->Close();
TabDef->Close();
db ->Close();
}
catch( CDaoException* e )
{
GestErroriDAO(e, db, TabDef, rec);
e->Delete();
}
delete rec;
delete TabDef;
delete db;
|
|
|
|
|
Did you search on the codeproject?
|
|
|
|
|
i created a modeless dialog box to my network application tool
when i right click on objects and opening the dialog box it is creating in a new seperate window plz help
i created like this
m_pEditPersonalityDlg->Create (IDD_PERSONALITY_DIALOG, AfxGetMainWnd());
|
|
|
|
|
Have a look at the dialog's styles in the resource editor. Have you told it to be a child window? And you may or may not want to change the border style as well.
Iain.
Iain Clarke appears because CPallini still cares.
|
|
|
|
|
ya irain its a chaild window i checked in resource editor style is pop up and border is dialog frame
if i keep style as child its not working its creating differently
i.e back side of the main app
|
|
|
|
|
Hi,
Also try using AfxGetApp()->m_pMainWnd instead of AfxGetMainWnd().
thanks ,
Nitheesh
|
|
|
|
|
No Niteesh not working with that same result
its unsolved problem for me since long time
|
|
|
|
|
girishchi@gmail.com wrote: ...it is creating in a new seperate window...
Instead of what?
The owner of a window is not necessarily the same as its parent. See here for more.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ya i got it we have to add setparent function in OnInit function
|
|
|
|
|
i have some problm to insert data into excel sheet. i hv configure the DSN name and the Workbook and also clear the read only option. i can read dat from that workbook as usual. But when i write the data then data is inserted only when , that worksheet is opened in task bar. data is not inserted when that worksheet is not opened in task bar. i am not able to find reason for that event.
i am sending the sample code for executing a query for excel sheet.
BOOL ExcuteStmtUpdate(char* Query)
{
SQLRETURN status;
int rc=-1;
SQLHSTMT StatementHandle;
long Roll;
SDWORD sdwALen;
int i;
//allocate statment handle
status = SQLAllocHandle (SQL_HANDLE_STMT,UpdateDBC.m_Connection,&StatementHandle);
if(status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
{
SQLFreeHandle (SQL_HANDLE_STMT, StatementHandle);
return false;
}
status = SQLPrepare(StatementHandle,(unsigned char*)Query,strlen(Query));
if(status == SQL_SUCCESS || status == SQL_SUCCESS_WITH_INFO)
{
status=SQLBindCol(StatementHandle, 1, SQL_C_SLONG,(PTR)&Roll, sizeof(Roll), &sdwALen);
//SQLExecute call
status = SQLExecute(StatementHandle);
if(!(status == SQL_SUCCESS || status == SQL_SUCCESS_WITH_INFO))
{
SQLFreeHandle (SQL_HANDLE_STMT,StatementHandle);
return false;
}
for (i = 1; (rc = SQLFetch(StatementHandle)) == SQL_SUCCESS; i++)
{
printf("%d ",Roll);
}
status=SQLEndTran(SQL_HANDLE_ENV,UpdateDBC.m_EnvironmentHandle, SQL_COMMIT);
}
else
{
SQLFreeHandle (SQL_HANDLE_STMT, StatementHandle);
return false;
}
SQLFreeHandle (SQL_HANDLE_STMT, StatementHandle);
return true;
}
|
|
|
|
|
here is a technique but iam not sure weather it is useful for your requirement.
simply do the file operations.
FILE *fp;
fp=fopen("C:\\test.xls","w");
fprintf(fp,"data1\n");
fprintf(fp,"data2\n");
fclose(fp);
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
modified on Thursday, April 10, 2008 6:40 AM
|
|
|
|
|
Are you kidding ? Do you know that excel files are binary files ?
|
|
|
|
|
all this i have done in my program. data is inserted when excel sheet is opened
is it possible or not, to insert data into excelsheet without MFC and Com component?
|
|
|
|
|
There are multiple layers of ignorance in this post. Perhaps the easiest to address is that C file handling is ugly as sin, I would never use it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: Perhaps the easiest to address is that C file handling is ugly as sin, I would never use it.
So do you use D or E file handling?
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|