The C program below print the first and last character of 16 words strings:
#include<stdio.h>
#include<string.h>
void main()
{
char first, last;
char *str = "abcdefghijklmnop";
first = str[0];
last = str[15];
printf("%s", &first);
printf("%s", &last);
}
The output I am seeking is a and p. But, when I run this code I get the output:
apa
What am I doing wrong?
below lines will bring correct result