Please look at the following:
Code:
#include <iostream.h>
void GetInput(char name[15]);
int main()
{
char word[15] = "Peter";
cout << "Original word:" << word << endl;
GetInput(word);
cout << "Finally:" << word << endl;
return 0;
}
void GetInput(char name[15])
{
cout << "Enter a name :";
cin >> name;
name = "John";
cout << "In function:" << name << endl;
}
The output is :
Quote:
quote:
Original word:Peter
Enter a name:Fred
In function:John
Finally:Fred
|
So why did Fred persist and John didn't ?
(I'm very new to C++ so please be gentle)
Gill BC