: : : Hi !!
: : :
: : : U need to allocate memory before using cin. Since memory has not been allocated to the variable therefore when cin in used it gives an error.
: : :
: : : Regards
: : : Shaunak
: : :
: :
: :
here's an example
: :
: : char *string = malloc(255);
: : cin >> string;
: :
: : or anoter example
: :
: : char string[255];
: : cin >> string;
: :
: :
:
: What's "Malloc"? I Forgot to say that I also did this:
:
: char* string = ""; //isn't this allocated?
: cin>>string;
:
: I saw that you could also define it as a static array, but that's dumb; you'd only be able to enter so many chars in a string!
: Isn't there a way to make it as many as you want? what is that "malloc" thing, are you giving it an address? isn't that the job of the compiler?
:
: Do you know what are some good includes for string manipulation?
: (I used to know C++, but we used the apclasses and I didn't have to deal with real C++ strings; now that I'm all used to java, some of this C++ stuff is weird to me)
:
malloc(255) will return a pointer to the new memory block of 255 bytes (characters) in size.