C源代码中的字符串 [英] Strings in C source code

查看:105
本文介绍了C源代码中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


在C中使用非报价终止字符串是否合法?


例如:


printf(Hello World

\ n);


而不是我通常使用的


printf(Hello World

" \ n");


我不相信,但有些编译器似乎允许这样做。只是想

确定我的编译器是否存在问题,或者确实是否允许使用
。 < OT>有没有人知道允许这个的编译器? < / ot>


谢谢

杰森。

Hello,

Is it legal to have a non-quote terminated string in C?

For example:

printf("Hello World
\n");

instead of what I normally use

printf("Hello World"
"\n");

I had believed not, but some compilers seem to allow this. Just want to
be sure if this is a problem with my Compiler, or if it really is
allowed. <ot> does anyone know of compilers that allow this? </ot>

Thanks
Jason.

推荐答案

它是不合法的。

It is not legal.


这不合法。见K& R2第7页。

It is not Legal. See K&R2 page 7.


Abhilash写道:
Abhilash wrote:
这是不合法的。




如果没有

将字符串更改为多个字符串以进行连接,那么字符串不能在行尾打破,但是要剪断

所有上下文仅适用于使用谷歌团体等玩家阅读

新闻组的人。



You are right that strings cannot be broken across end-of-lines without
changing them to multiple strings to be concatenated, but snipping away
all context only works for people using toys like google groups to read
newsgroups.


这篇关于C源代码中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆