summaryrefslogtreecommitdiffhomepage
path: root/c.html.markdown
diff options
context:
space:
mode:
authorPushkar Sharma <thepsguy@icloud.com>2015-10-04 10:34:31 +0530
committerPushkar Sharma <thepsguy@icloud.com>2015-10-04 10:34:31 +0530
commitc7e552c448c5a562a3ff5f442a7ed834aec04d9e (patch)
tree0584c659078e2290dcc21bf2e5cd25434172dba9 /c.html.markdown
parent9b46fe7e57bcf63785b67cdaffc49ff0d47d7476 (diff)
Variable size array, user size input added. #1170
Fixed Issue #1170 Variable size array, user size input added.
Diffstat (limited to 'c.html.markdown')
-rw-r--r--c.html.markdown4
1 files changed, 3 insertions, 1 deletions
diff --git a/c.html.markdown b/c.html.markdown
index 8e631de4..36621a9e 100644
--- a/c.html.markdown
+++ b/c.html.markdown
@@ -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