请检查什么';代码有什么问题吗 #包括 #内因库德 #包括 int main() { char ch[80]=“你好”/*这是字符串,输出应该是 元素:嗨,你好吗*/ int i; 对于(i=0;ch[i]!='\0';) { 如果(ch[i]='

请检查什么';代码有什么问题吗 #包括 #内因库德 #包括 int main() { char ch[80]=“你好”/*这是字符串,输出应该是 元素:嗨,你好吗*/ int i; 对于(i=0;ch[i]!='\0';) { 如果(ch[i]=',c,C,有两个循环。只有一个循环检查'\0' 编辑: for循环应该是这样的。请注意,计数器i++,您忘记了 #include <stdio.h> #inlcude <stdlib.h> #include <string.h> int main() { char ch[80] = "<Hi> How are you </Hi>"; /* This is the string, The output should be Element :

有两个循环。只有一个循环检查'\0'

编辑: for循环应该是这样的。请注意,计数器i++,您忘记了

#include <stdio.h>
#inlcude <stdlib.h>
#include <string.h>
int main()
{
char ch[80] = "<Hi> How are you </Hi>"; /* This is the string, The output should be 
   Element : Hi How are you */
int i;
for(i=0;ch[i] != '\0';) 
{
   if (ch[i] == '<' )
     {
       printf ("Element : ");
        i++;
           while(ch[i] != '<')  
                { 
                  if (ch[i] == '>') 
                     {  
                       printf(" ");
                         i++;
                     }
                  else
                     {
                        printf ("%c", ch[i]);
                         i++;
                     }
               }
       }
   else
      i++; 
  }

   return 0;
  }   
(i=0;i<10;i++)的

printf(“i:%d\n”,i);

你能先修复缩进并从gdb发布回溯吗?一个带有
#inlcude
指令的程序如何编译和运行?首先:#inlcude家伙..告诉循环中的代码有什么问题..@glglg它工作了..在内部循环中有一个
&&ch[i]!='\0'
缺失。猜猜为什么?我无法理解你..你能修复代码吗?嗨..你不需要为for循环使用I++吗..它仍然有效..我稍后给出了递增计数器..为什么我需要那个东西..它不会给出所需的输出。请看我的输出应该是“元素:你好吗?”另一个Hi是想要消除的..它实际上是打印标记名和其中的值..为什么我需要打印标记名的两倍?而且也不需要计数器..伙计们,继续..请正确检查代码..实际上我通过写入exit(1)来修复它在最后一个if循环结束大括号之前..问题是for循环无法找到我猜的'\0'东西。。
 for( i = 0; i < 10; i++)
   printf("i: %d\n", i);