這是一個bubble sort的小程式⋯陣列名稱=陣列的起始位置,所以我一開始是覺得用指標宣告也行⋯但沒想到⋯不太懂為什麼不能使用指標!
2条回答 默认 最新
- 加拉萨假期 2022-05-31 14:23关注
You declare a char pointer called str, but memory is not allocated to it. When you try to scanf, it will surely encounter segment fault error. Array is a data struct that memory is pre-allocated, so it works.
On the other hand, choosing char is not very wise, cause it take 1 byte with very a limited number range.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 SQL Server下载
- ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
- ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
- ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
- ¥15 python爬取bilibili校园招聘网站
- ¥30 求解达问题(有红包)
- ¥15 请解包一个pak文件
- ¥15 不同系统编译兼容问题
- ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
- ¥30 数字电源对DSP芯片的具体要求