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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -