Question: Use C to finish the function #define MAX GREETING This program has two arguments: the first is a greeting message, and the second is a

Use C to finish the function  Use C to finish the function #define MAX GREETING This program

#define MAX GREETING This program has two arguments: the first is a greeting message, and the second is a name. The message is an impersonal greeting, such as "Hi" or "Good morning". name is set to refer to a string holding a friend's name, such as "Emmanuel" or "Xiao", First copy the first argument to the array greeting. (Make sure it is properly null-terminated.) Write code to personalize the greeting string by appending a space and then the string pointed to by name. So, in the first example, greeting should be set to "Hi Emmanuel", and in the second it should be "Good morning Xiao". If there is not enough space in greeting, the resulting greeting should be truncated, but still needs to hold a proper string with a null terminator. For example, "Good morning" and "Emmanuel" should result in greeting having the value "Good morning Emmanu". int main(int argc, char xkargv) if (argc != 3) { fprintf(stderr, "Usage: greeting message name "); exit(1); char greeting [20]; char *name = argv[2]; // Your code goes here printf("%s ", greeting); return 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!