How to shift the character within the string in c? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to shift the character within the string in c?

ex: input: abc output : cab bca abc

12th Mar 2018, 9:16 AM
Jai Ganez
Jai Ganez - avatar
1 Answer
+ 2
Umm, I would imagine char arr[] = "abc"; int i,j; for (i = 0; i < 3; i++) { for (j = 0; j < 3 - 1; j++) { char temp = arr[j+1]; arr[j+1] = arr[j]; arr[j] = temp; } printf("%s\n", arr); }
12th Mar 2018, 10:24 AM
Hatsy Rei
Hatsy Rei - avatar