Jump to content

quick sscanf question in c

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
DaCapo

DaCapo

    Newbie

  • Members
  • Pip
  • 3 posts
Hello
I am programming in c
I am trying to use sscanf on a string
the sting looks like the following
{'2', '5', EOF, EOF, EOF, EOF, EOF, EOF, EOF, EOF}
I am trying to read a float

I get a segmentation fault. Any ideas why?

#2
chax

chax

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts

DaCapo said:

the sting looks like the following
{'2', '5', EOF, EOF, EOF, EOF, EOF, EOF, EOF, EOF}
I am trying to read a float

I get a segmentation fault.

Segmentation fault occurs when the memory allocated is not enough or is done improperly.
Why not read char when you are reading a string.
EOF is a macro constant definition. It expands to a negative integral constant expression.
Size does matter for science and its laws changes accordingly.
[SIGPIC][/SIGPIC]
An C

#3
DaCapo

DaCapo

    Newbie

  • Members
  • Pip
  • 3 posts
I actually just fixed the segmentation fault, sry bout that. But I still have a problem, whenever I do sscanf the value returned is not 25, it's some random value that changes everytime

#4
DaCapo

DaCapo

    Newbie

  • Members
  • Pip
  • 3 posts
I fixed it, sorry, it was a really dumb error, I was trying to read a float to a char.