Knowee
Questions
Features
Study Tools

Mark statements as T/F.True False int *p, i;char *cp, c;p = &i;cp = (char *)p;cp[2] = 'x';The last line of the above code modifies the variable i int *p; double *dp;sizeof(p) is 4 bytes while sizeof(dp) is 8 bytes. int *p;p[1] means *(p + 1) int *p; double *dp;p = p + 1 advances p by sizeof(int) bytes

Question

Mark statements as T/F.True False int *p, i;char *cp, c;p = &i;cp = (char *)p;cp[2] = 'x';The last line of the above code modifies the variable i int *p; double *dp;sizeof(p) is 4 bytes while sizeof(dp) is 8 bytes. int *p;p[1] means *(p + 1) int *p; double *dp;p = p + 1 advances p by sizeof(int) bytes

🧐 Not the exact question you are looking for?Go ask a question

Solution

  1. False. The last line of the code does not modify the variable i. It modifies the memory location that is 2 bytes ahead of where p is pointing.

  2. True/False. The size of pointers can vary depending on the system architecture. On a 32-bit system, both would be 4 bytes. On a 64-bit system, both would be 8 bytes.

  3. True. p[1] is equivalent to *(p + 1). This is because array indexing is essentially pointer arithmetic.

  4. True. p = p + 1 advances p by sizeof(int) bytes. This is because p is a pointer to an int, and the size of an int is typically 4 bytes.

This problem has been solved

Similar Questions

Mark statements as T/F.True False int *p, i;char *cp, c;p = &i;cp = (char *)p;cp[2] = 'x';The last line of the above code modifies the variable i int *p; double *dp;sizeof(p) is 4 bytes while sizeof(dp) is 8 bytes. int *p;p[1] means *(p + 1) int *p; double *dp;p = p + 1 advances p by sizeof(int) bytes

Fill in the blanks. In cpp">>"is _____ operator​

#ifndef main.h#define main.h#include <stddef.h>int _putchar(char c);int _islower(int c);int _isalpha(int c);int _abs(int n);int _isupper(int c);int _isdigit(int c);int _strlen(char *s);void _puts(char *s);char *_strcpy(char *dest, char *src);int _atoi(char *s);char *_strcat(char *dest, char *src);char *_strncat(char *dest, char *src, int n);char *_strncpy(char *dest, char *src, int n);int _strcmp(char *s1, char *s2);char *_memset(char *s, char b, unsigned int n);char *_memcpy(char *dest, char *src, unsigned int n);char *_strchr(char *s, char c);unsigned int _strspn(char *s, char *accept);char *_strpbrk(char *s, char *accept);char *_strstr(char *haystack, char *needle);#endif main.h~ ~ ~

Suppose that in a C program snippet, followings statements are used

13. Choose the correct statement that is a combination of these two statements,Statement 1: char *p;Statement 2: p = (char*) malloc(100);1) char p = *malloc(100);2) char *p = (char*)malloc(100);3) char *p = (char) malloc(100);4) None of the above

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.