Advanced_C_Programming_Answers
Advanced_C_Programming_Answers
Code:
int main() {
char *p;
p = &s[8]-8;
while(*p)
printf("%c", *p++);
Explanation: s[8] points to the null character '\0', so &s[8]-8 gives the address of s[0], i.e., 'T'.
The loop prints the string from the beginning till the null character. Output: Tendulkar
2. Significance of argv[0]:
argv[0] contains the name of the program being executed. It helps identify the running program in
command-line arguments.
int len = 0;
dest[len] = '\0';
Read 'n' words in a loop and track the word with maximum length using strlen().
Use a loop to compare each name in the array with the search string using strcmp().
8. Command-line argument:
*dest = '\0';
while(*str) {
str++;
iii. strlen(): Returns length of string. Syntax: size_t strlen(const char *str);
iv. strchr(): Finds first occurrence of character. Syntax: char *strchr(const char *str, int c);