想要一个“here doc”等同于“c”的 [英] want a "here doc" equivalent in "c"

查看:92
本文介绍了想要一个“here doc”等同于“c”的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在c程序中嵌入一个bash脚本。


你怎么能在c中执行以下bash片段?:


cat> / tmp / foo<< \\\ _EOD_

这里有各种令人讨厌的东西,包括单引号和双引号

和bashslashes ..

(请注意,此处的doc分隔符前面有一个\>

__EOD_


-

问候,

汤姆罗德曼

请运行我的地址:

perl -e''print unpack(" u"," 1 \\ \\:6UP\,\ $ \ T\< F\] D\; 6\%N\ + F\-O\; 0H\`");! '

解决方案

\!T \< F \] D \; 6 \%N \ + F \ - O\; 0H\`");''


2003年9月3日星期三15:14:28 -0500

Tom Rodman< Use-Author-Address-Header @ [127.1]>写道:

我想在c程序中嵌入一个bash脚本。


标准C不知道''嵌入'',''bash''或''脚本''。

你怎么能做下面的bash c中的片段?:

cat> / tmp / foo<< \__EOD_
这里有各种令人讨厌的东西,包括单引号和双引号
和bashslashes ..
(请注意,这里的doc分隔符前面有一个" \"
__EOD _




在comp.unix.programmer中询问并做好准备帮助,或者重新说明

问题不涉及任何特定于平台的事情。


-

char * x(c,k,s)char * k,* s ; {if(!k)返回* s-36?x(0,0,s + 1):s; if(s)if(* s)c = 10 +(c?(x(

c,k,0),x(c,k + = * sc,s + 1),* k):( x(* s,k,s + 1),0));否则c = 10; printf (& x(~0,0,k)[c-〜 -

c +" 1" [〜c< -c]],c);} main(){x( 0," ^ [kXc6] dn_eaoh


%C"," -34 * 1 ''。+(,03#; +,)/ '' /// * QUOT ;);}


I want to embed a bash script inside the c program.

How could you do the below bash snippet in "c"?:

cat > /tmp/foo <<\__EOD_
all kinds of nasty stuff in here including single and double quotes
and bashslashes ..
(note that the here doc delimiter is preceded by a "\"
__EOD_

--
regards,
Tom Rodman
pls run for my address:
perl -e ''print unpack("u", "1\:6UP\,\$\!T\<F\]D\;6\%N\+F\-O\;0H\`");''

解决方案

\!T\<F\]D\;6\%N\+F\-O\;0H\`");''


On Wed, 03 Sep 2003 15:14:28 -0500
Tom Rodman <Use-Author-Address-Header@[127.1]> wrote:

I want to embed a bash script inside the c program.
Standard C knows nothing of ''embed'', ''bash'' or ''script''.
How could you do the below bash snippet in "c"?:

cat > /tmp/foo <<\__EOD_
all kinds of nasty stuff in here including single and double quotes
and bashslashes ..
(note that the here doc delimiter is preceded by a "\"
__EOD_



Ask this in comp.unix.programmer and prepare to be helped, or rephrase the
question to something not involving anything platform-specific.

--
char*x(c,k,s)char*k,*s;{if(!k)return*s-36?x(0,0,s+1):s;if(s)if(*s)c=10+(c?(x(
c,k,0),x(c,k+=*s-c,s+1),*k):(x(*s,k,s+1),0));else c=10;printf(&x(~0,0,k)[c-~-
c+"1"[~c<-c]],c);}main(){x(0,"^[kXc6]dn_eaoh


%c","-34*1''.+(,03#;+,)/''///*");}


这篇关于想要一个“here doc”等同于“c”的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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