The goal of my exercise is to produce
The original string is:
silence .is a looking bird:the turning; edge, of life. e. e. cummings
Destination string after swapping: cummings e. e. life. of edge, turning; bird:the looking a .is silence
and what I am getting is:
69The original string is: silence .is a looking bird:the turning; edge, of life. e. e. cummings
Destination string after swapping:
my code: '''
#include<stdio.h>
#include<stdlib.h>
#define MAX_STR_LEN 1024
// DO NOT USE the string library <string.h> for this exercise
void wordSwapper(char *source, char *destination)
{
int count = 0;
while (*(source + count) != '\0')
{
count++;
}
printf("%d", count);
for(int i = 0; i < count; i++)
{
*(destination + i) = *(source + (count - i));
}
}
int main()
{
char source[MAX_STR_LEN]="silence .is a looking bird:the turning; edge, of life. e. e. cummings";
char destination[MAX_STR_LEN]="I am a destination string and I contain lots of junk 1234517265716572@qsajdkuhasdgsahiehwjauhiuiuhdsj!";
wordSwapper(&source[0], &destination[0]);
printf("The original string is: \n%s\n",source);
printf("Destination string after swapping: \n%s\n",destination);
}
'''