I'm trying to resize an array using realloc and it's telling me that the size is invalid but I'm not sure why since I'm using sizeof to get the correct size. Any ideas?
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int numberOfInputs;
char inputs[1];
void resize(char* c, int i);
int main()
printf("%s", "How many characters would you like to enter? ");
scanf("%d", &numberOfInputs);
if (numberOfInputs > 1)
{
resize(inputs, numberOfInputs);
}
printf("You input: %s", inputs);
}
void resize(char* c, int i)
{
c = (char*) realloc(c, sizeof(char) * i);
}