Is there a C function that does the same as raw_input in Python?
#in Python::
x = raw_input("Message Here:")
How can I write something like that in C?
Update::
I make this, but i get an error ::
#include<stdio.h>
#include<string.h>
#include "stdlib.h"
typedef char * string;
int raw_input(string msg);
string s;
string *d;
main(){
raw_input("Hello, Enter Your Name: ");
d = &s;
printf("Your Name Is: %s", s);
}
int raw_input(string msg){
string name;
printf("%s", msg);
scanf("%s", &name);
*d = name;
return 0;
}
and the error is that program run and print the msg, and take what user type by scanf, but then it hangs and exit.. ??
You can write one pretty easily, but you’ll want to be careful about buffer overflows:
Then use it like this:
You may want to add some error checking, and so on.