: : Hi,
: :
: : Your cin >> *name <---- this is incorrect - by doing this you are actually modifying only the first character of the string. What you want is cin >> name;
: :
: :
: : : I can't get this to work
: : :
: : : void main()
: : : {
: : : char string[20];
: : : char *aString = string;
: : : function (aString);
: : : }
: : : void function(char *name)
: : : {
: : : cout << "enter name";
: : : cin >> *name;
: : : cout << name;
: : : }
: : :
: :
: : I thought so, I thought they were trying to trick me
:
: Thanks so much
:
:
you don't need pointer aString. Just pass variable
string like this:
function (string);