以下代码使用gcc -std = c99在Linux上编译正常但在Visual Studio 2010 C编译器上获得以下错误:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. fib.c fib.c(42) : error C2057: expected constant expression fib.c(42) : error C2466: cannot allocate an array of constant size 0 fib.c(42) : error C2133: 'num' : unknown size
用户输入要生成的斐波那契数量.我很好奇微软编译器为什么不喜欢这段代码.
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
void fib(int max);
int main(int argc, char *argv[])
{
int argument;
if (argc != 2)
{
puts("You must supply exactly one …Run Code Online (Sandbox Code Playgroud)