How to read .txt file and find delimiter ?
-
Hi I try reading file through windows programming in vc++. My code like
DWORD wmWritten;
char strVal[1024];
dir = CreateFile(textBuffer,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
ReadFile(dir,strVal,1024,&wmWritten,NULL);textBuffer is my input file. i got all lines from text file. But want find some delimiter or i want return particular line text or (delimiter line text) Please give idea or sample code Regards, M.Mathivanan
-
Hi I try reading file through windows programming in vc++. My code like
DWORD wmWritten;
char strVal[1024];
dir = CreateFile(textBuffer,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
ReadFile(dir,strVal,1024,&wmWritten,NULL);textBuffer is my input file. i got all lines from text file. But want find some delimiter or i want return particular line text or (delimiter line text) Please give idea or sample code Regards, M.Mathivanan
Hi, you could scan the input, i.e. have a loop look at each of the characters in strVal after you filled it (make sure to use the return value of ReadFile as there may be less than 1024 characters read). it would be easier to use some higher-level I/O functions. Assuming you want C code, you could use fopen(), fread(), or better yet fgetline(). Look them up in your C book and in MSDN. And always check the return value you get from almost all Windows or C functions. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Hi I try reading file through windows programming in vc++. My code like
DWORD wmWritten;
char strVal[1024];
dir = CreateFile(textBuffer,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
ReadFile(dir,strVal,1024,&wmWritten,NULL);textBuffer is my input file. i got all lines from text file. But want find some delimiter or i want return particular line text or (delimiter line text) Please give idea or sample code Regards, M.Mathivanan
try strtok http://www.cplusplus.com/reference/clibrary/cstring/strtok/[^]
Величие не Бога может быть недооценена.
-
Hi I try reading file through windows programming in vc++. My code like
DWORD wmWritten;
char strVal[1024];
dir = CreateFile(textBuffer,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
ReadFile(dir,strVal,1024,&wmWritten,NULL);textBuffer is my input file. i got all lines from text file. But want find some delimiter or i want return particular line text or (delimiter line text) Please give idea or sample code Regards, M.Mathivanan
mathivanaan wrote:
But want find some delimiter...
Have you tried
strchr()
?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius