-
fscanf on sun's
hi,
have read of compatibility problems with fscanf. I have written a program which uses fscanf on windows. When I ran it on linux it worked fine. However I'm wanting to mainly use it on solaris (sun os) and for some reason it dosent work :-(
Have definetly isolated the problem as fscanf and it returns a bus error. Was wondering if you could point me in the right direction, if there is another function to use how would you get the same functionality as fscanf eg fscanf allows %d and %s seperated by comas extensively(i.e. fscanf(f,"%d , %d , %s , %d",%v,&x,&y,&z);)
-
if you have a fixed length record or if the records are seperate with a newline you could try fgets and sscanf.
Code:
char buffer[ 100 ];
fgets( buffer, sizeof( buffer ), file );
sscanf( buffer, "%d , %d , %s , %d", &v, &x, y, &z );
I suggest you look up fgets in your documentation, it may or may not work for you.
-
> I have written a program which uses fscanf on windows
The most likely cause of the problem is your code.
Just because it happens to work (or more likely appears to work) does not mean that it is bug free.