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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -