- #1
TheMathNoob
- 189
- 4
Homework Statement
I have a file which has data set in this way
1
2 3
4 7
1 2
I have to make a graph with those values considering that the value of the first line corresponds to the vertices and the next two values per line to the edges. I am having troubles with a function that doesn't detect if the first line has two values or not. If it does, then it should displayed an error.
Homework Equations
[/b]
Code:
int ParseN(char line[])
{
char* first;
char* second;
int true=1;
int numberVertices=0;
char* pt=strtok(line," -");
printf("%s",pt);
char* pt2=strtok(NULL," -");
printf("%s",pt2);
if(pt2==NULL) // in this case when I test my file with just one value in the first line, it doesn't detect the NULL
{
puts("yes");
}
else
puts("no");
return 1;
by the way sorry for not following the directions in the previous post. Now I understand what I have to do
The Attempt at a Solution
Last edited by a moderator: