N
Neil
I am working on a code that is supposed to return a string to my main
function from the test function. The cout in test returns "My Name",
but the cout in main returns some junk characters.
Can anyone tell me how I could fix it so I get "My Name" printed from
main also. Thanks.
#include <iostream>
using namespace std;
void test (char * temp[])
{
char name[] = "My Name";
temp[0] = name;
cout << temp[0] << endl;
}
int main ()
{
char* info[9];
test (info);
cout << info[0] << endl;
}
function from the test function. The cout in test returns "My Name",
but the cout in main returns some junk characters.
Can anyone tell me how I could fix it so I get "My Name" printed from
main also. Thanks.
#include <iostream>
using namespace std;
void test (char * temp[])
{
char name[] = "My Name";
temp[0] = name;
cout << temp[0] << endl;
}
int main ()
{
char* info[9];
test (info);
cout << info[0] << endl;
}