mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Variable size array, user size input added. #1170
Fixed Issue #1170 Variable size array, user size input added.
This commit is contained in:
parent
9b46fe7e57
commit
c7e552c448
@ -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;
|
||||
scanf("%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