Click here to Skip to main content
15,906,625 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: to send message to console exe Pin
Randor 27-Nov-11 11:15
professional Randor 27-Nov-11 11:15 
GeneralRe: to send message to console exe Pin
Albert Holguin28-Nov-11 7:46
professionalAlbert Holguin28-Nov-11 7:46 
AnswerRe: to send message to console exe Pin
Software_Developer27-Nov-11 7:46
Software_Developer27-Nov-11 7:46 
AnswerRe: to send message to console exe Pin
David Crow27-Nov-11 11:03
David Crow27-Nov-11 11:03 
QuestionDifferent GUI rendereng between WinXP and Vista-Win7 Pin
Bram van Kampen26-Nov-11 14:38
Bram van Kampen26-Nov-11 14:38 
Questionhow to read a character array line by line in C? Pin
robin70025-Nov-11 14:38
robin70025-Nov-11 14:38 
AnswerRe: how to read a character array line by line in C? Pin
robin70025-Nov-11 18:49
robin70025-Nov-11 18:49 
GeneralRe: how to read a character array line by line in C? Pin
enhzflep25-Nov-11 21:35
enhzflep25-Nov-11 21:35 
Okay, I'll byte..

In essence, you have a string that you have to cut up into smaller pieces.
The cut-points are clearly defined - the string is to be cut at the end of each line of text.

So, we need
1) knowledge of the number of lines
2) memory to hold each of the lines
3) to copy each of the lines to the memory allocated in step 2.


Sooo, you'll need to know what your line-ending character(or sequence) is. You'll need to count the number of instances of the of line terminators, and for ease and simplicity, add 1 to this number - this is the number of lines you have - mLineCount.
You can then create an array of mLineCount elements of char*
You can then copy each line, storing the address of the new text into the appropriate array element.


Two functions you'll likely make use of are strdup and strtok. I advise you read the documentation for these two functions carefully, there are a few gotchas or things to watch for with strtok - Particularly, the fact that it modifies the input string. This precludes the use of the function on const char* strings.



For example, while the intention below is to split "some text" into two separate strings, it will fail since strtok can't modify myString.

C++
char *myString = "some text", *delims = ",. ";
char *curToken;

curToken = strtok(myString, delims);

AnswerRe: how to read a character array line by line in C? Pin
Richard MacCutchan25-Nov-11 22:24
mveRichard MacCutchan25-Nov-11 22:24 
AnswerRe: how to read a character array line by line in C? Pin
CPallini26-Nov-11 0:45
mveCPallini26-Nov-11 0:45 
GeneralRe: how to read a character array line by line in C? Pin
enhzflep26-Nov-11 0:59
enhzflep26-Nov-11 0:59 
GeneralRe: how to read a character array line by line in C? Pin
CPallini26-Nov-11 1:11
mveCPallini26-Nov-11 1:11 
QuestionWaitForSingleObject, Run do loop, win32 api Pin
jkirkerx25-Nov-11 13:44
professionaljkirkerx25-Nov-11 13:44 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
Chris Meech25-Nov-11 14:13
Chris Meech25-Nov-11 14:13 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx25-Nov-11 15:18
professionaljkirkerx25-Nov-11 15:18 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
Randor 25-Nov-11 14:24
professional Randor 25-Nov-11 14:24 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx25-Nov-11 15:19
professionaljkirkerx25-Nov-11 15:19 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
Chuck O'Toole25-Nov-11 15:05
Chuck O'Toole25-Nov-11 15:05 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx25-Nov-11 15:20
professionaljkirkerx25-Nov-11 15:20 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
Erudite_Eric26-Nov-11 9:15
Erudite_Eric26-Nov-11 9:15 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx26-Nov-11 12:37
professionaljkirkerx26-Nov-11 12:37 
QuestionRe: WaitForSingleObject, Run do loop, win32 api Pin
Randor 26-Nov-11 13:35
professional Randor 26-Nov-11 13:35 
AnswerRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx26-Nov-11 16:39
professionaljkirkerx26-Nov-11 16:39 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
Randor 27-Nov-11 6:33
professional Randor 27-Nov-11 6:33 
GeneralRe: WaitForSingleObject, Run do loop, win32 api Pin
jkirkerx27-Nov-11 9:07
professionaljkirkerx27-Nov-11 9:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.