I am trying to get the user to enter a sentence, then I change that sentence to say hi.
My error - arguement char not compataible with paramater char
If you see any other errors please let me know.
If you can show me how it should be done, I would appreciate it.
Vlad- 100 elements of *Code1 to initialize it?
Framework - Right. I forgot about parentheses. In this, how do I modify this input(&output[2]); ?
At this I thought input
(&(output[2]))
but it says cant use char with char?
If I removed the asterick for
char*code1[]
It will not be a pointer anymore though? Please bear with me as this is my first time and explain how the 2 pointers came about when I only used one *
It was never a pointer to an array anyway; it was an array of pointers.
By passing the array by reference, you don't need to explicitly specify the address. For example:
1 2 3 4 5 6 7 8 9 10 11 12
void Function(int(&ArrayOf100)[100])
{
// ...
}
int main()
{
int MyArray[100] = { 0 };
// Pass the array to Function()
Function(MyArray);
}
Note the absence of the address-of operator. References do not require you to pass it the address. Passing by pointer (or reference) requires you to pass the address. For example:
1 2 3 4 5 6 7 8 9 10 11 12
void Function(int(*ArrayOf100)[100])
{
// ...
}
int main()
{
int MyArray[100] = { 0 };
// Pass the array to Function()
Function(&MyArray);
}
#include <iostream>
#include <string>
usingnamespace std;
void input(char *code)
{
cout <<"\n\n enter your sentence (this is the input fn)" << endl;
cin >> code;
}
int main()
{
char output[20];
input(output);
cout<<"\n\n enter the sentence (this is the main fn)";
cin>>output;
cout << output << endl;
system("pause");
}
#include <cctype> // for tupper()
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
// This is where we will keep the text that the user gives us:
string s;
// Ask the user for text and get it:
cout << "Enter your sentence: ";
getline( cin, s );
// As this is an example, let's make the output SHOUTING:
for (size_t n = 0; n < s.length(); n++)
{
s[ n ] = toupper( s[ n ] );
}
// Display the changes we made to the user's input:
cout << s << endl;
return 0;
}