Dumb Question: What is sscanf?
Please don't bash me. I really don't understand it. I know how to use sprintf and stuff but sscanf?
On a tutorial is says:
Quote:
.....sscanf is just like scanf, only it gets the input from a string
Doesn't ssprint do the same thing?
Code:
#include <iostream>
#include <cstdio>
#include <cstdlib>
using std::cin;
int main( int argc, char *argv[] )
{
char Buffer[255];
char Name[255];
printf("Input your name: ");
scanf( "%s", Name );
sprintf( Buffer, "Your Name: %s", Name );
printf("%s", Buffer);
cin.get();
return 0;
}
Re: Dumb Question: What is sscanf?
Quote:
Originally posted by KingZoolerius66
Please don't bash me. I really don't understand it. I know how to use sprintf and stuff but sscanf?
Doesn't ssprint do the same thing?
No. sprintf() takes a bunch of values and creates a string, like
-- printf() to screen output
-- sprintf() to a string buffer
sscanf() takes a string and breaks it up into values, like
-- scanf() input from keyboard
-- sscanf() input from a string buffer