C++, C-Strings ! That's my problem: http://screencast.com/t/sBjt9Dzoq7RZ That's my code: http://pastebin.com/TLXgMRJk It asks for me to copy one string to another without using predefined functions apart from gets(). as strcpy() is a predefined function , I can't use this to solve my problem. Is there another way to copy one string to another ? Please help me. Thanks a lot for reading .
May I know what your codes do?
All of my codes are attempts to solve this problem: http://screencast.com/t/sBjt9Dzoq7RZ This here is my latest code: http://pastebin.com/pzF5bDmP I still can't do it though
s1 and s2 are of string type?
they are strings yes
char type
char type? Why?
The int type was giving me some extra errors. Plus why not char type ?
string s1 ^Type string
Now the errors got more
For example I can't use gets() now
Well, their instructions contradict themselves.... if you were not able to use predefined functions how could you print? Hehe. But I think they mean for the copy. I'm looking at the code now.
yea most likely ;p
AH! Your loop! ``` for (i=0; S1[i]!='\0';i++){ } ``` Nothing in that.
In this loop I just want i++ so that I can say var = i
after the loop is over
OK. So you are using it to find the last position. I would normally copy inside the loop that way.
Took the life out of me :p
Hehe. The fun thing is, you could do it all in one loop. Copy and cout one right after the other, stopping when you hit the null.
can you show me ??
I'll have to do it later. Need to head to work pretty soon.
ok man its np
It can be really good to see more than one way to do things. That is why I have shared some alternate solutions after you were done with your other projects.
Yea they are interesting too
Join our real-time social learning platform and learn together with your friends!