Code doesn't work, VScode doesn't show any errors.

Dhruv Karmali 0 Reputation points
2023-12-08T17:14:57.2266667+00:00

#include <stdio.h> #include <stdlib.h> int main(void) { int list= malloc(3sizeof(int)); if(list==NULL) { return 1; }

int i =0;
while (i<3)
{
    printf("Give a value: "); 
    scanf("%d",&list[i]);
    i++;
    printf("YES!\n");
}

int*tmp =malloc(4*sizeof(int));
if(tmp==NULL)
{
    free(list);
    return 1;
}

for(int i=0;i<3;i++)
{
    tmp[i]=list[i];
    printf("No!\n");
}

printf("Give a value: ");
scanf("%d",tmp[3]);
free(list);
list=tmp;

for(int i=0;i<4;i++)
{
    printf("%i\n",list[i]);
    printf("Why!\n");
}
free(list);
return 0;

}

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,404 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,904 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 74,451 Reputation points
    2023-12-08T17:56:30.4833333+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.