so im trying to run one of my functions in my program and im getting a error that I've attached below. Im not sure what it is saying or how to fix it. could someone help me?
This is the function code its referring to:
The error quite literally says what's wrong: as its first argument it expects a pointer to a file, but instead you have passed it an array of characters.
Stephan van Hulst wrote:The error quite literally says what's wrong: as its first argument it expects a pointer to a file, but instead you have passed it an array of characters.
To read from a string, use sscanf.
scanf - read and parse data from stdin
fscanf - read and parse data from a file
sscanf - parse data from a string (buffer)
printf has similar relatives.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
fscanf is what you use when you want a single function to both read in a line of text and process it.
sscanf is what you use when you have already read in the line in a separate operation. Or if you got the line from a database or some other source/constructor and want to process it.
And actually, "scanf()" is just shorthand for "fscanf( stdin, ... )"
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
That sounds like the C/C++ equivalent of a NullPointerException. The "4" is often a reference to memory location (address) 4, which would not be a valid memory reference on most hardware platforms - for application programs, anyway. As to why "4" instead of "0" - well there are reasons, but they don't matter. Any memory reference down in the bottom of RAM is likely a problem.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.