Two questions

Hello my friend
cin in c++ means console input?

and

Why do we have the second error?
1-
#include <iostream.h>
int main ()
{
char *p;
char *str="example";
p=str;
cout<<*p<<endl;
cout<<" string= "<<str;
return 0;
}

2-

#include <iostream.h>
int main ()
{
char *p;
char *str="example";
*p=str;
cout<<*p<<endl;
cout<<" string= "<<str;
return 0;
}
Last edited on
Yes, cin is console input.

p has the type char*.
*p has the type char.
str has the type char*.

You can only assign compatible types, char and char* are not compatible.

http://www.cplusplus.com/doc/tutorial/pointers/
Cin means "C++ Input" if I am not mistaken. "Console Input" wouldn't make too much sense because cin isn't always reading from the console - cin may be just as well a ifstream or something the like.
Topic archived. No new replies allowed.