References

I'm supposed to create a function that takes a char& argument and modifies that argument. In main, print out a char variable, call the function for that variable, and print out again to prove that it has been changed.
I've tried a few times but I cant seem to do it correctly. Can someone please show me an example of how I'm supposed to do this.
Hi @stiches,
this is fairly simple,
let me know if
i am missing something
and post what you
have so far (code)
this is an example,

regards!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//change_char.cpp
//##

#include <iostream>
using std::cout;
using std::endl;


//function prototype
void change_char(char& someChar);

int main(){

char character='A';

        cout<<"Character: "<<character<<endl;
        change_char(character);
        cout<<"\nCharacter after calling\n \"change_char\" function : ";
        cout<<character<<endl;

return 0; //indicates success
}// end of main


void change_char(char& someChar){
        someChar='B';
}//end function change_char
Character: A

Character after calling
 "change_char" function : B
That's is what I thought I had to do. I must have forgoten somthing haha Thanks
Well
you are welcome!
Topic archived. No new replies allowed.