Dec 20, 2011 at 6:10pm UTC
What's the stdio equivalent of cin and if there is one, how is it used?
Dec 20, 2011 at 6:35pm UTC
I don't mean to sound rude, but isn't printf the equivalent of cout?
Dec 20, 2011 at 6:40pm UTC
Last edited on Dec 20, 2011 at 6:42pm UTC
Dec 20, 2011 at 6:44pm UTC
Is there a simpler example. It's a bit confusing for me.
Dec 20, 2011 at 7:22pm UTC
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 Dec 20, 2011 at 7:23pm UTC
Dec 20, 2011 at 7:26pm UTC
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.