Can someone tell me what is going on here? why isnt it only copying the first 3
ID: 3527785 • Letter: C
Question
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 beRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.