mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-23 06:03:07 +03:00
Merge pull request #1329 from thePsguy/patch-2
{c}Variable size array, user size input added.
This commit is contained in:
commit
2a337bef67
@ -130,7 +130,9 @@ int main(void) {
|
||||
// can be declared as well. The size of such an array need not be a compile
|
||||
// time constant:
|
||||
printf("Enter the array size: "); // ask the user for an array size
|
||||
char buf[0x100];
|
||||
int size;
|
||||
fscanf(stdin, "%d", &size);
|
||||
char buf[size];
|
||||
fgets(buf, sizeof buf, stdin);
|
||||
|
||||
// strtoul parses a string to an unsigned integer
|
||||
|
Loading…
Reference in New Issue
Block a user