Aug 23, 2012 at 8:56pm UTC
Hey Guys,
From the coding, how can I pass a word instead of a character only?
#include <iostream>
using namespace std;
void print(char &);
void print(char &array)
{ cout<<array<<endl; }
int main()
{
char array[5]={'a'};
print(array[0]);
return 0;
}
Looking forward for the guidance. Thank You =)
Aug 23, 2012 at 9:03pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
using namespace std;
void print(char * array)
{ cout<<array<<endl; }
int main()
{
char array[5]={'a' , 'b' , 'c' , 'd' , 0};
print(array);
return 0;
}
Last edited on Aug 23, 2012 at 9:04pm UTC
Aug 23, 2012 at 9:04pm UTC
Why don't you just use std::string
?
Aug 26, 2012 at 11:01am UTC
Thanks for the Respond guys, really appreciate it.
How could I only print one of the value? For example, I have a-d and I only want to print c?
Thanks =)
Aug 26, 2012 at 11:27am UTC
http://stackoverflow.com/questions/7902433/passing-array-arguments-by-reference