Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function called getstring() that accepts a prompt stored as a string (pa

ID: 3673281 • Letter: W

Question

Write a function called getstring() that accepts a prompt stored as a string (passed by reference into the function), prints that prompt to the screen, gets a string from the user, and then stores the user entered string back into the string that was passed into the routine. The following code will allow you to test your function to see if it works properly. Be sure to include the following code with your submitted program. When writing your function, scanf() and printf() should not be used. Instead, getchar() and putchar() should be used to get and print characters. The function getchar() returns a character. The function putchar() takes the character to be printed as an argument. Submit this problem as hw3p3.c. #include ,aom( ) { char *prompt; prompt = "Enter a sentence: "; getstring (&prompt;); printf("%S",prompt) ;//The string printed should be what the user entered }

Explanation / Answer

#include<stdio.h>

int main()

{

char *prompt;

while(*prompt !=’ ’)

{

putchar(*prompt);

prompt++;

}

prompt=’ ’;

getstring(&prompt);

printf(“%s”,prompt);

getch();

return 0;

}

getstring(char* prompt)

{

while (*prompt!=’ ’)

{

putchar(*prompt++);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote