Strings - Programming

Q1:

What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str = "AptitudeCrack";
    printf("%s\n", str);
    return 0;
}

A Error

B AptitudeCrack

C Base address of str

D No output

ANS:A - Error

The line char str = "AptitudeCrack"; generates "Non portable pointer conversion" error. To eliminate the error, we have to change the above line to char *str = "AptitudeCrack"; (or) char str[] = "AptitudeCrack"; Then it prints "AptitudeCrack".