|
Post by loyalgurl on Oct 29, 2005 20:41:44 GMT 5.5
hi all i am bak with another question on pointers..Can anybody write function taht accepts 2 char ** variables as arguments and swaps them? I tried really hard for it..but cud not c any clue anywhere... No this not any kinda assignment but just a question... help needed really urgent.......got an exam tommorow.. thanks a lot bye for now take care
|
|
|
Post by loyalgurl on Nov 1, 2005 6:12:23 GMT 5.5
hi all i know pointers suck...that is y there is no reply here....till now.... neways it is ok...will try to get help frm someone... hav fun bye for now
|
|
|
Post by Saurabh Jain on Nov 2, 2005 15:22:25 GMT 5.5
Hiii I got one e -mail regarding this problem from wadud sujon here me writing that email content
"Wadud Sujon" <awsujon@yahoo.com> wrote....
probably you have tried in the following way:
void swap(char **s1,char **s2){ char **temp;
temp=s1; s1=s2; s2=temp; } it will not work........
you can try the following funtion....
void swap(char **s1,char **s2){ char **temp; temp= new char[size_of_each_string];
for each string{ strcpy(temp,s1[0]); strcpy(s1[0],s2[0]); strcpy(s2[0],temp); } }
if you need the explanation, plz don't hesitate to knock me..
wadud sujon phd candidate Image processing lab kyung hee uni. (suwon campus) south korea
|
|
|
Post by loyalgurl on Nov 2, 2005 22:22:32 GMT 5.5
hi thanks for the help.... but the pronlem i m encountering with this is that the strcpy() founction accepts char* as arguments and here we r trying to pass char **. So the warning msg taht i am getting is as follows : warning: passing arg 1 of 'strcpy' from incompatible pointer type warning: passing arg 2 of 'strcpy' from incompatible pointer type
any further suggestions??? thanks a lot for help again bye for now
|
|