07-27-2023, 09:58 AM
I need to use `fscanf` to ignore all the white spaces and to not keep it.
I tried to use something like the combination between `(*)` and `[^\n]` as: `fscanf(file," %*[^\n]s",);`
Of course it crashed, is there any way to do it only with `fscanf`?
code:
int funct(char* name)
{
FILE* file = OpenFileToRead(name);
int count=0;
while(!feof(file))
{
fscanf(file," %[^\n]s");
count++;
}
fclose(file);
return count;
}
Solved !
change the original `fscanf()` to :
`fscanf(file," %*[^\n]s")`;
read all the line exactly as `fgets()` but didnt keep it!
I tried to use something like the combination between `(*)` and `[^\n]` as: `fscanf(file," %*[^\n]s",);`
Of course it crashed, is there any way to do it only with `fscanf`?
code:
int funct(char* name)
{
FILE* file = OpenFileToRead(name);
int count=0;
while(!feof(file))
{
fscanf(file," %[^\n]s");
count++;
}
fclose(file);
return count;
}
Solved !
change the original `fscanf()` to :
`fscanf(file," %*[^\n]s")`;
read all the line exactly as `fgets()` but didnt keep it!