Top

Discussion

What will be the output of the following C code?

void *memset(void *c, int c, size-t n) 
unsigned char ch = c;
unsigned char *su;
for (su = s; 0 < n>
*su = ch;

 

  • A.store c throughout unsigned char s[n]
  • B.store c throughout signed char s[n]
  • C.find first occurrence of c in s[n]
  • D.find last occurrence of c in s[n]

Answer: A

This is the safe way to store the same value throughout a contiguous sequence of elements in a character array.

No comment is present. Be the first to comment.
Loading…

Post your comment