Reading text files into an array in C -


just got question regards, when read lines of text text file how separate words , store them array.

for example if have 2 lines of text in text file looks this:

1005; andycool; andy; anderson; 23; la 1006; johncool; john; anderson; 23; la

how split them based on ';' . , store them in 2d array.

sorry haven't started coding yet paste here

cheers ...

use strsep function:

char* token; char* line;  /* assume line loaded file  */;  if( line != null ) {   while ((token = strsep(&line, ";")) != null)   {      /*           token points current extracted string,           use fill array        */   }  } 

Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -