12. Suppose that a character string named my-name has been declared and allocate
ID: 3720008 • Letter: 1
Question
12. Suppose that a character string named my-name has been declared and allocated at length 100. Write a statement that would set its contents to your name. 13. Suppose that a character string named my-name has been declared and allocated at length 100. Write a printf statement that outputs to stdout the string variable's contents, followed by a newline. 14. Suppose you have two character string variables declared, allocated and filled with contents (some text). How would you tell whether the first string were less than, equal to or greator than the second string?Explanation / Answer
12.
strcpy(my_name, "name");
13.
printf("%s ",name);
14.
Let str1 and str2 are the string variables
strcmp(str1,str2);
The result
-> zero when both strings are found to be identical.
-> greater than zero if str1 > str2
-> less than zero if str1 < str2
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.