Can someone tell me what is going on here? why isnt it only copying the first 3 letters in the string and what is with this crazy str1 output value? #include #include using namespace std; int main(){ int a,i; char str[15], str1[15]; strcpy(str, "steak"); for(i=0; i>=2 ;i++) str[i]=str1[i]; cout<<str1; cout<<"press enter"; cin>>a; return 0;} I dont want to use strcpy because I only want to copy part of the string If anyone knows a better way to only copy part of a string to another please tell me.
Explanation / Answer
first of all the for loop has error{ for(i=0; i>=2 ;i++)} the condition will not satisfy , either i should be