What is the problem in this program?
char * CutString(const char * str1)
{
    char str2[4]; 
    strncpy(str2, str1, 3); 
    str2[3] = '\0';    //1 
    return str2;  
}
int main()
{
      char * s = CutString("aaaaaaa");
      std:cout<<(s);
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes