cin equivalent for stdio?

What's the stdio equivalent of cin and if there is one, how is it used?
printf("Your message here");
http://www.cplusplus.com/reference/clibrary/cstdio/printf/

Putting values in here is a little more difficult than with cin, but it also works.
I don't mean to sound rude, but isn't printf the equivalent of cout?
Whoa, complete mind-fart..

Anyways, you're looking for scanf();

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

usage:
scanf ("%d",&i);
This will input an integer into int i.
Last edited on
Is there a simpler example. It's a bit confusing for me.
Try this...

1
2
3
4
5
6
7
8
9
10
11
12
#include <cstdio>

int main()
{
 char szBuffer[256];

 printf("Type Something, Then Press [ENTER]... ");
 gets(szBuffer);
 printf("\n\nszBuffer = %s\n",szBuffer);

 return 0;
}


With MinGW compiles to 6 K.
Last edited on
The term...

char szBuffer[256]

creates a 256 byte block of memory your program's main function owns. gets (get string) will put typed characters into that buffer. printf with a %s format specifier will output it to the screen.
Topic archived. No new replies allowed.