Friday, August 7, 2015

swapping string

#include <stdio.h>

#include<string.h>

int main()
{
    int  i ;
    char  temp ;

    char  profile[2][10] = {"koushik","Akif"} ;

    printf ( "\nBefore swapping: %s %s", &profile[0][0], &profile[1][0] ) ;

    for ( i=0 ; i <=10 ; i++ )
    {
        temp = profile[0][i] ;
        profile[0][i] = profile[1][i] ;
        profile[1][i] = temp ;
    }
    printf ( "\nAfter swapping: %s %s", &profile[0][0], &profile[1][0] ) ;


}




output:                                                                  


No comments:

Post a Comment