你能告诉我这个问题的解释吗? [英] Can u tell me the explanation reg this problem

查看:97
本文介绍了你能告诉我这个问题的解释吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果程序(myprog)从命令行运行为myprog 1 2 3,

输出是什么?

main(int argc,char * argv [])

{

int i;

for(i = 0; i< argc; i ++)

printf("%s",argv [i]);

}

解释这些命令行参数以及它们是如何的

实际阅读

以下程序的输出是什么?

main()

{

char near * near * ptr1;

char near * far * ptr2;

char near * huge * ptr3;

printf(" ;%d%d%d,sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));

}

Plzz还解释了???



你可以推荐一些我可以上网的好书吗?

问题

If the program (myprog) is run from the command line as myprog 1 2 3 ,
What would be the output?
main(int argc, char *argv[])
{
int i;
for(i=0;i<argc;i++)
printf("%s",argv[i]);
}
Explain a lil bit abt these command line arguments and how they are
actually read
What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
Plzz also explain how???


Can u suggest any good books which i can get online for referring such
questions

推荐答案

2006-06-05,Sree< gi ***** @ gmail.com>写道:
On 2006-06-05, Sree <gi*****@gmail.com> wrote:
如果程序(myprog)从命令行运行为myprog 1 2 3,
输出是什么?
我想,答案就在你面前。除非你对''输出'的概念不清楚


main(int argc,char * argv [])
int main(int argc ,char * argv)

{
int i;
for(i = 0; i< argc; i ++)
printf("%s",argv [一世]);
返回0;这些命令行参数以及它们是如何实际阅读的解释一下......这对于b $ b''lil''和''abt''不是单词。

以下程序的输出是什么?
试试吧。

main()
int main(void){
char near * near * ptr1;
char near * far * ptr2;
char near * huge * ptr3;
printf("%d%d%d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
返回0; }
near,far和huge不是C关键字。你应该得到语法错误。

Plzz也解释了如何???

你能否提出任何好的书籍,我可以上网参考这样的问题
If the program (myprog) is run from the command line as myprog 1 2 3 ,
What would be the output? I imagine that the answer would be right in front of you. Unless you
are unclear on the concept of ''output''.
main(int argc, char *argv[]) int main (int argc, char *argv)
{
int i;
for(i=0;i<argc;i++)
printf("%s",argv[i]); return 0; }

Explain a lil bit abt these command line arguments and how they are
actually read
''lil'' and ''abt'' are not words.

What would be the output of the following program? Try it and see.
main() int main (void) {
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3)); return 0; } near, far, and huge aren''t C keywords. You should get syntax errors.

Plzz also explain how???

Can u suggest any good books which i can get online for referring such
questions



''Plzz'',''u''和小写''i''不是单词。你还使用了太多

的问号。一个就够了。


-

Andrew Poelstra< http://www.wpsoftware.net/blog >

给我发电子邮件,请使用apoelstra。在上面的地址。

如果我们只是让偷猎者进入动物园,我们会给b
$ b更少的人和更多花式钢琴!


''Plzz'', ''u'', and lowercase ''i'' are not words. You also used too many
question marks. One is enough.

--
Andrew Poelstra < http://www.wpsoftware.net/blog >
To email me, use "apoelstra" at the above address.
If we would just let the poachers into the zoo, we''d
have less squashed people and more fancy pianos!





Sree在06/05/06 13:43写道:


Sree wrote On 06/05/06 13:43,:
如果程序(myprog)是从命令行运行myprog 1 2 3,
什么是输出?
main(int argc,char * argv [])
{
int i;
for(i = 0; i< argc; i ++)
printf("%s",argv [i]);
}


开一些系统,输出将是


myprog123

然而,程序中有一些令人讨厌的小错误

可能导致其他事情发生:


- 它调用printf()而不显示函数原型。

添加`#include< stdio.h> ;''开头。


- 它不会以换行符结束输出。

在某些系统上,这将导致交互式提示

出现在输出之后


myprog123tardis>


在其他系统上,输出可能根本不显示。


- 它无法从main()

函数返回一个'int''值来表明程序是否成功

或失败。在某些系统上,这可能会产生一个

输出,比如


myprog123

%RMS-F-BADFILE,文件结构已损坏

解释这些命令行参数的漏洞以及它们是如何实际读取的。


如何命令行参数被解析,准备,

并交给程序取决于命令行读取
的系统。不同的系统以不同的方式执行,并且
可以对自己进行各种修改,替换您键入的

字符。例如,某些Unix

系统会将'myprog~'视为实际输入

`myprog / home / sree''。这类细节不是C语言的一部分,而应该在一个专门用于你正在使用的系统的论坛上。


最后程序的main()函数接收一些

值,这些值以某种方式从命令行派生和/或

其他部分环境。这些表示为

字符串序列,argv []

数组的第一个argc元素指向字符串的初始字符。第一个

字符串(如果有任何字符串; argc可以为零)是一些

类型的程序名称表示,但只是它的内容

看起来像是再次进入主机系统:它可能是

myprog或myprog.exe或或SYS
If the program (myprog) is run from the command line as myprog 1 2 3 ,
What would be the output?
main(int argc, char *argv[])
{
int i;
for(i=0;i<argc;i++)
printf("%s",argv[i]);
}
On some systems, the output would be

myprog123

However, there are some nasty little errors in the program
that might cause other things to happen:

- It calls printf() without a function prototype visible.
Add `#include <stdio.h>'' at the beginning.

- It does not end its output with a newline character.
On some systems this will cause the interactive prompt
to appear right after the output

myprog123tardis>

On other systems, the output might not appear at all.

- It fails to return an `int'' value from the main()
function to indicate whether the program succeeded
or failed. On some systems, this may produce an
output like

myprog123
%RMS-F-BADFILE, file structure is corrupt
Explain a lil bit abt these command line arguments and how they are
actually read
"How" the command-line arguments are parsed, prepared,
and handed to the program depends on the system that reads
the command line. Different systems do it differently, and
may make various modifications of their own, replacing the
characters you type with others. For example, some Unix
systems will treat `myprog ~'' as if you had actually typed
`myprog /home/sree''. Details of this kind are not part of
the C language, and should be taken up on a forum devoted
to the system you are using.

Eventually the program''s main() function receives some
values that are somehow derived from the command line and/or
other parts of the environment. These are represented as a
sequence of strings, and the first argc elements of the argv[]
array point to the strings'' initial characters. The first
string (if there are any strings; argc can be zero) is some
kind of representation of the program name, but just what it
looks like is once again up to the host system: it might be
"myprog" or "myprog.exe" or "SYS


DISK:[HOME.SREE] MYPROG.EXE; 3"

或更不可理解的东西。在大多数系统上,

剩余的字符串将是1,2和3,尽管C

语言无法保证之前发生的确切情况main()

被调用。最后,argv [argc]

永远都是NULL,也就是说,最后一个真实的是真的。字符串指针是

后跟一个NULL指针。

以下程序的输出是什么?
main()
{
char near * near * ptr1;
char near * far * ptr2;
char near * huge * ptr3;
printf("%d%d%d",sizeof(ptr1) ,sizeof(ptr2),sizeof(ptr3));
}


我不知道;它不是C.

Plzz也解释了如何???


你可以推荐一些我可以上网参考这样的好书吗? />问题
DISK:[HOME.SREE]MYPROG.EXE;3"
or something even less understandable. On most systems the
remaining strings will be "1", "2", and "3", although the C
language cannot guarantee exactly what happens before main()
is called. Finally, it will always be true that argv[argc]
is NULL, that is, that the last "real" string pointer is
followed by a NULL pointer.
What would be the output of the following program?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
I don''t know; it isn''t C.
Plzz also explain how???


Can u suggest any good books which i can get online for referring such
questions




我什么都不知道(这并不代表不存在,只是

我不喜欢不知道他们)。 C编程语言

(第二版)由Kernighan& Ritchie是一本值得推荐的

硬拷贝书。


-
Er ********* @ sun.com



I don''t know of any (that doesn''t mean none exist, just
that I don''t know of them). "The C Programming Language"
(second edition) by Kernighan & Ritchie is a highly recommended
hard-copy book.

--
Er*********@sun.com


这篇关于你能告诉我这个问题的解释吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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