 <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; //#include &lt;stdbool.h&gt; int main() { int m,n,t,i; char a[]="National University"; char b[]="India"; char c[100]; char d[100]; m=strlen(a); n= strlen(b); if(m&gt;n) { t=m; // strcpy(&amp;c,&amp;a); for(i=0;i&lt;n;i++) d[i]=b[i]; for(i=0;i&lt;m-n;i++) d[n+i]=32; for(i=0;i&lt;t;i++) { a[i]=a[i]^d[i]; d[i]=d[i]^a[i]; a[i]=a[i]^d[i]; } printf("a= %s \t b=%s" ,a,d); } else { t=n; // strcpy(&amp;d,&amp;b); for(i=0;i&lt;m;i++) c[i]=a[i]; for(i=0;i&lt;n-m;i++) c[m+i]=32; for(i=0;i&lt;t;i++) { c[i]=c[i]^b[i]; b[i]=b[i]^c[i]; c[i]=c[i]^b[i]; } printf("c= %s \t d=%s" ,c,b); } return 0; } </code></pre> <p>This way you can do it.You just need a loop for swapping each character. EDIT: Now its dynamic. You need not to specify length manually and I am appending NULL character at the end of shorter string. Look result at :<a href="http://ideone.com/B7lsz4" rel="nofollow">http://ideone.com/B7lsz4</a></p>