Make an array of strings

Hello friends. Can I create an array of strings extracting data from a CSV file?

Data in CSV file:

20132,AREA,SUPERFICIE,VOLUMEN,PRESION,TEMPERATURA,VELOCIDAD,ACELERACION
12312,TEMPERATRA,ACELERACION,VOLUMEN,PRESION,TEMPERATURA,,
32313,FLUJO,CAUDAL,PRESION,,,,
34324,MASA,GRAVEDAD,,,,,

I imagine something like this:

char* myStrings[]={"20132", "AREA", "SUPERFICIE", "VOLUMEN", "PRESION","TEMPERATURA", "VELOCIDAD", "ACELERACION"};

And that also could choose the row according to the first data search.

Two errors:

  1. char *myStrings is a pointer to a char, not a char. So char *myStrings is a array of pointers...

  2. a c-string is a array of it's own. So a array of strings gives you a 2 dimentional array. myString, but you can only ommit the size of the first dimension. So you must enter the length of the strings (don't forget room for the termination) aka the size of the longest string => myStrings[12]. This leaves you with unused space for shorter strings. So it might not be the greatest thing to do... But it all depends on what you want to do with the strings....

gomez696:
Hello friends. Can I create an array of strings extracting data from a CSV file?

Data in CSV file:
I imagine something like this:

char* myStrings[]={"20132", "AREA", "SUPERFICIE", "VOLUMEN", "PRESION","TEMPERATURA", "VELOCIDAD", "ACELERACION"};

And that also could choose the row according to the first data search.

What you could easily do is to declare a null-terminated string variable which can hold one line from your file:

char line[81];  // can hold lines up to 80 characters length

Then you read in your file line by line, and if you want to seperate the data within the line, you could use the strtok() standard string function in a for-loop to get the contents of each data field within the line.