Tuesday, 15 March 2011

text - Tokenize from a textfile reading into an array in C -


How can you find out when you read from a file in C

Textfile:

PES 2009; Kanami; DD3; 500.25; 6

Ascin cult; Ubisoft; DD; 598.25; 3

Inferno; EA; DVD 2; 650.25; 7

  char * tokenPtr; FileT = fopen ("DATA2.txt", "r"); / * This * / tokenPtr = strtok (file T, ";") will not work; While (tokenPtr! = NULL) {printf ("% s \ n", tokenPtr); TokenPtr = strtok (NULL, ";"); }  

Would like to print it:

PES 2009

Konami

.

Try it:

  main () {FILE * f; Four S 1 [200], * P; F = fopen ("yourfile.txt", "r"); While (fgets (s1, 200, f)) {

  while (fgets (s1, 200, f)) {p = strtok (s1, "; \ n"); Do {printf ("% s \ n", p); } While (P = Stroke (NULL, "; \ n")); }  

No comments:

Post a Comment