1
Exit status -1
Yuvikiit (0)

This is my code and I am not getting why is it showing exit status -1.
Please answer:)
#include<stdio.h>
#include<string.h>
int main()
{
int i;
char c,d,e;
scanf("%s",c); //to take in the 1st string
scanf("%c",&d);//after string the newline char needs to get in the buffer
scanf("%s",e); //to take in another string
printf("%s\n%s",c,e); //to print both the strings
return 0;
}

You are viewing a single comment. View All
Answered by mwilki7 (111) [earned 5 cycles]
View Answer
1
mwilki7 (111)

Here is a sample program that does this:

Program (allocate with array sharing)

#include <stdio.h>

int main()
{
    char *c;       // declare pointer
    char arr[20];  // declare array
    
    c = arr;       // array shares space with c
    
    scanf("%s", c);// write stuff to c
    
    printf("c: %s, arr: %s",c,arr); // print results
    
    return 0;    
}

Input

test

Output

c: test, arr: test