String swapping problem
anonymous_at_coolgroups.com
Date: 05/17/04
- Next message: Régis Troadec: "Re: function call in conditional operator?"
- Previous message: bnp: "function call in conditional operator?"
- Next in thread: Régis Troadec: "Re: String swapping problem"
- Reply: Régis Troadec: "Re: String swapping problem"
- Reply: Case: "Re: String swapping problem"
- Reply: Lew Pitcher: "Re: String swapping problem"
- Reply: Rob van der Leek: "Re: String swapping problem"
- Reply: A: "Re: String swapping problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 17 May 2004 12:39:34 GMT
Hi CLCers,
I tried the following code for swapping a string, but it is
not working. Inside the swap function the strings are
printed correctly, but when back in main() the strings are
not swapped at all. Thanks in advance. Here is the code.
#include<stdio.h>
int main()
{
void swap(char * string1, char * string2);
char * string1 = "Hello World";
char * string2 = "Hello Jupiter";
swap(string1, string2);
printf("%s\n%s\n",string1,string2);
return 0;
}
void swap( char * string1, char * string2)
{
char * temp;
temp = string1;
string1 = string2;
string2 = temp;
printf("%s\n%s\n",string1,string2);
}
Sha
- Next message: Régis Troadec: "Re: function call in conditional operator?"
- Previous message: bnp: "function call in conditional operator?"
- Next in thread: Régis Troadec: "Re: String swapping problem"
- Reply: Régis Troadec: "Re: String swapping problem"
- Reply: Case: "Re: String swapping problem"
- Reply: Lew Pitcher: "Re: String swapping problem"
- Reply: Rob van der Leek: "Re: String swapping problem"
- Reply: A: "Re: String swapping problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
Loading