这段话什么意思啊?大神进来看看

flying_music 2016-04-12 08:18:45

C语言现在支持这种变成数组吗?怎么我的编译器不行啊?这在底层也没法实现吧
...全文
164 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
灌水号 2016-04-12
  • 打赏
  • 举报
回复
引用 5楼我是你的主体 的回复:
[quote=引用 2 楼 qq423399099 的回复:] 变长数组GCC是可以编译的,如果楼主是VS什么的是通不过编译的
gcc确实可以,但是怎么实现的呢?我试了一下,确实给数组在栈上分配空间了,而且随着输入值的不同分配的空间还不同,这用到了什么高新技术吗?[/quote]这个数组是在栈上的,其效果相当于你定义了n*n个行参,其实也是压栈而已,数组太大容易溢出。
赵4老师 2016-04-12
  • 打赏
  • 举报
回复
请那些喜欢将数组作为函数参数传来传去的码农思考一下为什么不把整个互联网内容当作函数参数传来传去呢?
flying_music 2016-04-12
  • 打赏
  • 举报
回复
引用 2 楼 qq423399099 的回复:
变长数组GCC是可以编译的,如果楼主是VS什么的是通不过编译的
gcc确实可以,但是怎么实现的呢?我试了一下,确实给数组在栈上分配空间了,而且随着输入值的不同分配的空间还不同,这用到了什么高新技术吗?
flying_music 2016-04-12
  • 打赏
  • 举报
回复
引用 3 楼 paschen 的回复:
C99支持变长数组VLA,但C++里是没有的
奥,好吧,那底层是怎么实现的啊?编译器怎么知道该分配多少内存呢
paschen 2016-04-12
  • 打赏
  • 举报
回复
引用 4 楼 cyfcsd 的回复:
[quote=引用 3 楼 paschen 的回复:] C99支持变长数组VLA,但C++里是没有的
奥,好吧,那底层是怎么实现的啊?编译器怎么知道该分配多少内存呢[/quote] http://blog.163.com/163_zhujingwei/blog/static/973305972011519114611170/
paschen 2016-04-12
  • 打赏
  • 举报
回复
C99支持变长数组VLA,但C++里是没有的
小灸舞 版主 2016-04-12
  • 打赏
  • 举报
回复
变长数组GCC是可以编译的,如果楼主是VS什么的是通不过编译的
cocoabird 2016-04-12
  • 打赏
  • 举报
回复
参数n必须在A[n][n]之前初始化
赵4老师 2016-04-12
  • 打赏
  • 举报
回复
VMMap 是进程虚拟和物理内存分析实用工具。http://technet.microsoft.com/zh-cn/sysinternals/dd535533
赵4老师 2016-04-12
  • 打赏
  • 举报
回复
引用 8 楼 cyfcsd 的回复:
[quote=引用 6 楼 zhao4zhong1 的回复:] 请那些喜欢将数组作为函数参数传来传去的码农思考一下为什么不把整个互联网内容当作函数参数传来传去呢?
不是要传整个互联网啊,是编译器怎么“提前”知道用户输入的啊[/quote] 我的意思是研究怎样将数组作为函数参数或函数返回值是浪费生命的一种方法。 默认栈大小参考: /STACK (Stack Allocations) Home | Overview | How Do I | Linker Options The Stack Allocations (/STACK:reserve[,commit]) option sets the size of the stack in bytes. To find this option in the development environment, click Settings on the Project menu. Then click the Link tab, and click Output in the Category box. The Reserve text box (or in the reserve argument on the command line) specifies the total stack allocation in virtual memory. The default stack size is 1 MB. The linker rounds up the specified value to the nearest 4 bytes. The optional value specified in the Commit text box (or in the commit argument on the command line) is subject to interpretation by the operating system. In Windows NT, it specifies the amount of physical memory to allocate at a time. Committed virtual memory causes space to be reserved in the paging file. A higher commit value saves time when the application needs more stack space, but increases the memory requirements and possibly the startup time. Specify the reserve and commit values in decimal or C-language notation. Another way to set the size of the stack is with the STACKSIZE statement in a module-definition (.DEF) file. STACKSIZE overrides the Stack Allocations (/STACK) option if both are specified. You can change the stack after the .EXE file is built by using the EDITBIN tool.
flying_music 2016-04-12
  • 打赏
  • 举报
回复
好像明白了 确实是用户输入后栈指针又移动了 并没有什么高新技术 这么简单的问题为什么别的编译器不支持呢
flying_music 2016-04-12
  • 打赏
  • 举报
回复
引用 7 楼 u014444402 的回复:
[quote=引用 5楼我是你的主体 的回复:][quote=引用 2 楼 qq423399099 的回复:] 变长数组GCC是可以编译的,如果楼主是VS什么的是通不过编译的
gcc确实可以,但是怎么实现的呢?我试了一下,确实给数组在栈上分配空间了,而且随着输入值的不同分配的空间还不同,这用到了什么高新技术吗?[/quote]这个数组是在栈上的,其效果相当于你定义了n*n个行参,其实也是压栈而已,数组太大容易溢出。[/quote] 恩 压栈的问题我知道 就是不明白当系统调用main函数时是如何确定main栈帧大小的 难道是等用户输入后再移动栈指针?
flying_music 2016-04-12
  • 打赏
  • 举报
回复
引用 6 楼 zhao4zhong1 的回复:
请那些喜欢将数组作为函数参数传来传去的码农思考一下为什么不把整个互联网内容当作函数参数传来传去呢?
不是要传整个互联网啊,是编译器怎么“提前”知道用户输入的啊

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧