请检查以下语法并更正它有4个错误 [英] please check the below syntax and correct it it has 4 errors
本文介绍了请检查以下语法并更正它有4个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
main()
{
char *name;
int length;
char *cptr = name;
name = "DELHI";
printf {"%s\n", name};
while{*cptr != '\0'}
{
printf{"%C is stored at address %u\n", *cptr, cptr};
cptr++;
}
length = cptr - name;
printf{"\nLength of the string = %d\n", length};
}
推荐答案
为你固定。
Fixed for you.
#include <stdio.h>
int main()
{
char *name;
name = "DELHI";
int length;
char *cptr = name;
printf ("%s\n", name);
while(*cptr != '\0')
{
printf("%C is stored at address %p\n", *cptr, cptr);
cptr++;
}
length = cptr - name;
printf("\nLength of the string = %d\n", length);
return 0;
}
顺便说一句,你真的很喜欢花括号,不是吗?
By the way, you really like curly braces, don't you?
你系统地错放了{和}
第7行:printf {%s \ n,name}; - > printf(%s \ n,姓名);
第8行:while {* cptr!='\ 0'} - > while(* cptr!='\ 0')
第10行:printf {%C存储在地址%u \ n,* cptr,cptr}; - > printf(%C存储在地址%u \ n,* cptr,cptr);
第14行:printf {\\\
Length of the string =%d \ n,length}; - > printf(字符串的\\\
Length =%d \ n,长度);
You systematically misplaced "{" and "}"
Line 7: printf {"%s\n", name}; -> printf ("%s\n", name);
Line 8: while{*cptr != '\0'} -> while(*cptr != '\0')
Line 10: printf{"%C is stored at address %u\n", *cptr, cptr}; -> printf("%C is stored at address %u\n", *cptr, cptr);
Line 14: printf{"\nLength of the string = %d\n", length}; -> printf("\nLength of the string = %d\n", length);
这篇关于请检查以下语法并更正它有4个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文