hi can any one say if i can copy one pointer to another with a string added to the second pointer before copying.i did try using stringcopy but i couldn't get result.so can anyoine help me
I didn't get your question properly . If you want to copy two strings of pointers . Here is a single line code:<br><br>while(*dest++ = *source++);<br><br>Does it answer your question ?<br>Thanx<br>Siddhartha Singh<br><A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A>
If i interpret your question correctly you have<br>one pointer such as<br>char * test1 = "whatever"<br>then have a string<br>say<br>char [] test2 = "example ";<br>You can then copy the characters from test1 to test2<br>bye putting it in a loop like<br><br>for (int i = 8; i <= 18; i++)<br> test2<i> = *(test1++);<br><br>this copies the characters from one to another, just <br>becarefull not to copy the memory address of the pointer<br>and that you actually have the additional room in the <br>string. oh all the statements might no be exact it has been awile since i did c <br><br>hope this helps ackka <p>moses<br><a href=mailto:tmoses@iname.com>tmoses@iname.com</a><br><a href=
My problem is i am using two pointers in a function which is called in main , so as and when i come out of the fucntion i have to get all the contants of the pointer cleared so that when i call the function again i get as if i am using a new pointer else when i am call the fuction again the arguments r getting added to the pointer.like<br><br>main(){<br>char *des1<br>char *scr1<br>char *name1;<br>char *value1;<br><br> fun_text(des1,scr1,name,value);<br>}<br><br>void fun_text(char *des,char *scr,char *name,char *value)<br>{<br><br>coding for function...<br>}<br><br><br>here in the above for the first time my fuction is working fine but when i call it second time its giving me problem,the arguments i am passing r getting added to the previous pointer only.<br><br>sugget a way where in i can clear the contents of pointer in function<br>
O.k , You do one thing . When you are going to call the function next time. Just do<br>src = NULL;<br>dest = NULL;<br>But one question are you allocating memory to the pointers any where or not ?<br>If not then behaviour would be different.<br><br>Does this answer your question ?<br>Thanx<br>Siddhartha Singh<br><A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.