怎么了? [英] What is wrong?

查看:61
本文介绍了怎么了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我有这个功能:


int扫描(char String [])

{

printf("%s",String);

}


它有效但当我尝试传递一个虚线字符串o separetad with(",

" _"," - " ... ecc)

它只返回第一个单词。

我以这种方式传递字符串:


char CString [] =" I.am.an.example" ;;

Scan(CString );


怎么了?

请帮帮我!

Thx!

Hi everybody!
I have this function:

int Scan(char String[])
{
printf("%s", String);
}

it works but when I try to pass a dotted string o separetad with (" ",
"_" , "-" ...ecc)
it return only first word.
I pass the string in this way:

char CString[] = "I.am.an.example";
Scan(CString);

What''s wrong?
Help me please!
Thx!

推荐答案

fe **** **********@tiscali.it 写道:

大家好!

我有这个功能:


int扫描(字符串[])

{

printf("%s",String);

}
Hi everybody!
I have this function:

int Scan(char String[])
{
printf("%s", String);
}



你声明函数返回为int但是你不要回报

什么的。考虑将其更改为:

void扫描(char String []);

You declared the function as returning as int but you don''t return
anything. Consider changing it to:
void Scan(char String[]);


它可以工作,但是当我尝试传递一个虚线字符串o separetad with(",

" _"," - " ... ecc)

它只返回第一个单词。
it works but when I try to pass a dotted string o separetad with (" ",
"_" , "-" ...ecc)
it return only first word.



它应该打印数组中的所有字符,直到第一个

null字符。当然应该打印点和短划线。


您是否检查过您的阵列中是否包含任何空字符

在有效数据结束之前嵌入?

Well it should print all the characters in the array upto the first
null character. Certainly dots and dashes should be printed.

Have you checked that your array doesn''t contain any null characters
embedded before the end of valid data?


我以这种方式传递字符串:


char CString [] =" I.am.an.example" ;;

扫描(CString);


有什么问题?
I pass the string in this way:

char CString[] = "I.am.an.example";
Scan(CString);

What''s wrong?



直到你可以向我们展示一个完整的,可编辑的例子来展示你的b $ b问题,(复制并粘贴代码,不要''重新输入它),我们可以做更多的比b / b
继续猜测。

Until you can show us a complete, compilable example that exhibits your
problem, (copy & paste the code, don''t retype it), we can do much more
than keep guessing.


fe ************** @ tiscali.it 写道:
fe**************@tiscali.it wrote:

int Scan(char String [])

{

printf("%s",String);

}


它有效,但是当我尝试传递一个带有(",

" _" ;, - " ... ecc)

它只返回第一个单词。
int Scan(char String[])
{
printf("%s", String);
}

it works but when I try to pass a dotted string o separetad with (" ",
"_" , "-" ...ecc)
it return only first word.



它什么都不返回;大概你的意思是它打印出来。

It returns nothing; presumably you mean that it prints that.


我以这种方式传递字符串:


char CString [] =" ; I.am.an.example;

扫描(CString);


有什么问题?
I pass the string in this way:

char CString[] = "I.am.an.example";
Scan(CString);

What''s wrong?



其他的东西。


发布一个小的,可编译的代码示例来说明问题。

它不在你上面​​发布的无法编译的片段中。


例如,当我编译并运行这个程序时:


#include < stdio.h>


int Scan(char String [])

{

printf("%s" ,String);

}


int main(无效)

{

char CString [ ] =" I.am.an.example";


扫描(CString);


getchar();

返回0;

}


结果是完整地打印了I.am.an.example。


Richard

Something else.

Post a small, compilable sample of code that demonstrates the problem.
It is not in the uncompilable snippets you posted above.

For example, when I compile and run this program:

#include <stdio.h>

int Scan(char String[])
{
printf("%s", String);
}

int main(void)
{
char CString[] = "I.am.an.example";

Scan(CString);

getchar();
return 0;
}

the result is that I.am.an.example is printed, in its entirety.

Richard




Richard Bos写道:

Richard Bos wrote:
fe ************** @ tiscali.it 写道:
fe**************@tiscali.it wrote:

int Scan(char String [])

{

printf("%s",String);

}


它有效,但是当我尝试传递一个点缀的字符串o separetad with(" ",

" _" , - ... ecc)

它只返回第一个字。
int Scan(char String[])
{
printf("%s", String);
}

it works but when I try to pass a dotted string o separetad with (" ",
"_" , "-" ...ecc)
it return only first word.



它什么都不返回;大概你的意思是它打印出来。


It returns nothing; presumably you mean that it prints that.


我以这种方式传递字符串:


char CString [] =" ; I.am.an.example;

扫描(CString);


有什么问题?
I pass the string in this way:

char CString[] = "I.am.an.example";
Scan(CString);

What''s wrong?



还有别的。


发布一个小的,可编译的代码示例来说明问题。

它不在你上面​​发布的无法编译的片段中。


例如,当我编译并运行这个程序时:


#include < stdio.h>


int Scan(char String [])

{

printf("%s" ,String);

}


int main(无效)

{

char CString [ ] =" I.am.an.example";


扫描(CString);


getchar();

返回0;

}


结果是完整地打印了I.am.an.example。


Something else.

Post a small, compilable sample of code that demonstrates the problem.
It is not in the uncompilable snippets you posted above.

For example, when I compile and run this program:

#include <stdio.h>

int Scan(char String[])
{
printf("%s", String);
}

int main(void)
{
char CString[] = "I.am.an.example";

Scan(CString);

getchar();
return 0;
}

the result is that I.am.an.example is printed, in its entirety.



我不相信! (我的意思是,从你那里,这个小小的单据。)

(看看 http ://snipurl.com/iqxx

I don''t believe that! (I mean, from you, this little slip.)
(Look at http://snipurl.com/iqxx)


这篇关于怎么了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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