鱼C论坛

 找回密码
 立即注册
查看: 2993|回复: 6

S1E21:指针课后作业-报警告

[复制链接]
发表于 2022-9-8 17:45:39 | 显示全部楼层
本帖最后由 jackz007 于 2022-9-8 17:48 编辑
  1. #include <stdio.h>
  2. #include <string.h>

  3. int main(void)
  4. {
  5.         char st[5][100], ch                                                ;
  6.         int i , j , min , max                                              ;
  7.         for(i = 0 ; i < 5 ; i ++) {
  8.                 printf("请输入第%d句话:", i + 1)                          ;
  9.                 for(j = 0 ; (ch = getchar()) != '\n' ; j ++) st[i][j] = ch ;
  10.                 st[i][j] = '\0'                                            ;
  11.         }
  12.         printf("你输入了下边5句话:\n");
  13.         for (i = 0 , min = max = 0 ; i < 5 ; i ++) {
  14.                 printf("%s\n" , st[i])                                     ;
  15.                 if(strlen(st[i]) > strlen(st[max])) max = i                ;
  16.                 if(strlen(st[i]) < strlen(st[min])) min = i                ;
  17.         }
  18.         printf("其中最长的是:%s\n", st[max])                              ;
  19.         printf("其中最短的是:%s\n", st[min])                              ;
  20. }
复制代码

        这个代码用 VC6.0、tdm-gcc 编译均无任何警告
tdm-gcc:
  1. D:\[00.Exerciese.2022]\C>g++ -o x x.c

  2. D:\[00.Exerciese.2022]\C>
复制代码

VC 6.0
  1. D:\[00.Exerciese.2022]\C>cl x.c
  2. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
  3. Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

  4. x.c
  5. Microsoft (R) Incremental Linker Version 6.00.8447
  6. Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

  7. /out:x.exe
  8. x.obj

  9. D:\[00.Exerciese.2022]\C>
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-9-8 19:08:06 | 显示全部楼层
阿亮不减肥 发表于 2022-9-8 18:36
主要是莫名其妙的出现个警告,还是想弄明白为啥

       要想弄明白,你得贴出编译器给出的这条警告信息的内容。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-26 06:00

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表