I'll explain my issue in this way.
I've use a structure to get some data of a byte stream as follows.
1. struct pac_cont
2. {
3. unsigned int des_list ;
4. unsigned int mem_ID ;
5. unsigned char dm_con ;
6. unsigned char ser_ID ;
7. unsigned short act ;
8. };
Now I want to write some values finding by using above variables, to a text file, of a function. Try it as follows.
1. void dataExtract(int length, char *buffer)
2. {
3. struct pac_cont* p = (struct pac_cont*)buffer;
4.
5. printf("dest %d member %d data %d ser %d act %d\n",p->des_list,p->mem_ID,p->dm_con,p->ser_ID,p->act) ;
6.
7. ofstream filedata ;
8. filedata.open( "RecordData.txt", ios::app ) ;
9.
10. if(filedata.is_open())
11. {
12. filedata << p->des_list << "\t" << p->mem_ID << "\t" << p->dm_con << "\t"<< p->ser_ID << "\t" << p->act << "\n";
13.
14. filedata.close() ;
15. }
16. else
17. {
18. filedata << "Wrong\n" ;
19. }
20. }
That printf gives the exact values I need on the command prompt. But the line filedata give some annoying output to the text file. I know that how format the output in printf, but no idea how to use in filedata
Someone can give a clue to me.
Thanks