I am new to C++ having trouble in assigning value to char* of a function. I have a function as below which returns bool
bool Function(char* inString)
{
int m = strlen(inString);
char output[1001];
memset(output , 0 , sizeof(output));
sprintf_s(output,50,"length is %d",m);
if(m>5)
return true;
if(m<5)
return false;
}
Along with the function , i am trying to get the "output" value on calling this function outside defined local inside this function which has value - "length is -"
I tried doing
bool Function(char* inString)
{
int m = strlen(inString);
char output[1001];
memset(output , 0 , sizeof(output));
sprintf_s(output,50,"length is %d",m);
sprintf_s(inString,50,output);
if(m>5)
return true;
if(m<5)
return false;
}
But this fails because inString has already a value and this is giving following error Access violation writing location 0x00165267.
Is there any way to get both parameters from this function ( bool value based on string length) as well as b) the string statement "output"?
I appreciate your help..
m==5
? Your functions doesn't cover returns for all possibilities. – Alexandru Barbarosie