i am currently playing with functions and trying to figure out how they work. in my piece of code i am looking at taking a users input and then calling a function and using the users input that i took and having it as an input to my function .
the variable 'data' is what i am taking from the user and when i bring it to the function it doesnt work . what i have read from the book is that data as i see it is called a global variable and it should be defined through the program , but the function cant see it . i dont get this bit . the strStringID if assigned works but its the overlapping part of using data and bringing to the function which i cant get to work. i have got bogged down in this now and i am lost at this stage , i need to play around with this in all forms to get used to them, if any one has any light on this it would help cheers , john. i have a feeling i am doing something wrong with the data type of the function as it clashes with the users input data type , if that makes sense.
#include <iostream>
#include <string>
using namespace std;
char fun(string);
char data;
int main()
{ cout << "please enter an id";
cin >> data;
fun(data);
system ("PAUSE");
return 0;
}