Wrriten in C Program. Write a function, thirdstring , which creates a new string
ID: 3878602 • Letter: W
Question
Wrriten in C Program. Write a function, thirdstring, which creates a new string where every second and third characters of the first string are skipped.
For example: "John Smith" would become "Jnmh"
Requirements:
*The function prototype must be: void thirdstring(const char [ ], char [ ]);
*Think how you will use the two parameters.
*As a result, you will have both the resulted string and the original one.
*Do not use ANY system-defined string functions (i.e. those found in the string.h library including but not limited to strlen, strcat, and strcpy.).
Explanation / Answer
here is your program : ------------------->>>>>>>>>>>>>>>>
#include<stdio.h>
void thirdstring(const char first[],char third[]){
int i = 0;
int j = 0;
while(first[i] != ''){
third[j] = first[i];
j++;
i++;
if(first[i] == '')
break;
i++;
if(first[i] == '')
break;
i++;
}
}
int main(){
char first[] = "John Smith";
char third[20];
thirdstring(first,third);
printf("Third String = %s",third);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.