scanf problem....

cin.get = to???
Last edited on
What data type are you trying to read in? scanf is not like cin where you can just read in anything. You have to specify what type of data should be expected.
@zeak

Do you mean - Does scanf have the equivalent of ignore & get ?

With ignore, the answer is no. scanf does return a value of how many items were successfully read, so you should test this.

http://www.cplusplus.com/reference/cstdio/scanf/


With get, it reads a single char - so it is easy to do this with scanf.

I saw your other topic about this same problem - what part of the scanf page do you not understand?

Remember to always read the documentation - there is lots of info in the reference section at the top left of this page.

And Google C++ scanf ? Someone said the other day that Google seems to be a dying black art - I tend to agree these days. Can you imagine what it was like learning to code without the internet? It makes me appreciate the internet a lot - but a lot of people can't seem to be bothered in this day & age. People seem to prefer asking questions rather than spending 2 seconds on Google search.

Of course this criticism doesn't apply if you live somewhere like Iran or Nth Korea where Google isn't allowed.
Last edited on
The exact equivalent would be scanf("%*1000[^\n]%*1[\n]%*c"); but the equivalent to what you're most likely trying to do is simply scanf(" %*c");
Topic archived. No new replies allowed.