0
My program is printing the letter P instead of i, I would like to understand the problem behind this and what is wrong in my code. If I put the letter A instead of O, the program would print the letter B.
#include <stdio.h>
#include <stdlib.h>
int main (){
char *p = {'O', 'i'};
p++;
printf("%c\n", p);
}
If I put
1in themalloc ()the code continues to function normally and shows thei, wouldn’t it be right to allocate 1 byte for each index? Somalloc (2)can allocate thep[0]andp[1]. Thank you for your response.– kodakz
https://i.stack.Imgur.com/zdAbK.jpg. It is right to allocate one byte for each index, so 2.
– Maniero