J
Jeff0803
Guest
I want to read string using cin, assign to char* and then call function where return just 5 characters.
I made code like following but it doesn't work.
#include <iostream>
using namespace std;
char* GetFiveChar(char* instr)
{
char* resultstr = { 0 };
memcpy(resultstr, instr, 5);
return(resultstr);
};
int main()
{
char* inputFileName = { 0 };
cin >> inputFileName;
cout << GetFiveChar(inputFileName);
}
Can anybody make it work?
Continue reading...
I made code like following but it doesn't work.
#include <iostream>
using namespace std;
char* GetFiveChar(char* instr)
{
char* resultstr = { 0 };
memcpy(resultstr, instr, 5);
return(resultstr);
};
int main()
{
char* inputFileName = { 0 };
cin >> inputFileName;
cout << GetFiveChar(inputFileName);
}
Can anybody make it work?
Continue reading...