请检查以下语法并更正它有4个错误

编程入门 行业动态 更新时间:2024-10-11 19:16:02
本文介绍了请检查以下语法并更正它有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个错误

本文发布于:2023-11-22 06:09:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616264.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法   请检查   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!