Hey guys! I'm new to C, so i would like help in one problem. I have to separate a string and put him into diferent variables. Imagine, Sol 3 5 would result in something like:
var1=Sol
var2=3
var3=5
I tried to use the scanf, but it stoped in the first space :/ .
Thanks in advance!
Cheers!
EDIT: Isn't my homework, i'm just practicing, but i really want to now how I can do this :) . The code I have now is this:
int main () {
char var1[10],var2[10],var3[10],func;
fgets(func, 20, stdin);
fscanf(func,"%s %d %d", var1,var2,var3);
printf("%s %d %d", var1,var2,var3);
return 0;
}
funcneeds to be an array, scanf needs to receive pointers (&), var3 and var3 shoudl have been integers and fscanf receives a FILE*, not a string.