How to extract a subsequence from a cahr array

hi, I am hemanth.

I am inputting data as lines.

like

4 3 4 5 6
6 45 65 54 44 34 34

I am Extracting lines using Gets function like
char line[1000];
gets(line);

so, line array contains "4 3 4 5 6"

how to extract the five integer elements from it.

hemanth.avs
If you are programming in C++ you can use stringstreams
eg:
1
2
3
stringstream ss ( "1 2 3" );
int a,b,c;
ss >> a >> b >> c;

If you are programming in C, you can use sscanf
eg:
1
2
int a,b,c;
sscanf ( "1 2 3", "%d %d %d", &a, &b, &c );




http://www.cplusplus.com/reference/iostream/stringstream/
http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/
Topic archived. No new replies allowed.