有人帮忙! [英] Someone help!
问题描述
我在代码下面编写,但无法通过编译。有人可以帮助这个吗?
---------------------------- -
#include< stdlib.h>
#include< stdio.h>
#include< string.h>
使用命名空间std;
struct Entry {
char name [15];
int number;
};
条目phone_book [1000];
inline void print_entry( int i);
int main()
{
const char phone_book [3] .name [15] =" ;我爱你!; //我想
将字符串分配给char数组但是失败:(
print_entry(3);
system(" PAUSE");
返回0;
}
void print_entry(int i)//简单使用
{
cout<< phone_book [i] .name<<''''<<< phone_book [i] .number<<< '\ n''<<" I
通过" ;;
}
cssh ... @ gmail.com写道:
我在代码下面编写但无法通过编译。可能有人帮助
这个?
------------------------------
#include< stdlib.h>
这样做:
#include< cstdlib>
#include< stdio.h>
制作:
#include< iostream>
#include< string.h>
这样做:
#include< string>
>
使用命名空间std;
struct Entry {
char name [15];
更改为:
字符串名称;
int number;
};
条目phone_book [1000];
inline void print_entry(int i );
删除单词inline从上面看 - 它没有任何意义,除非
你实际上在这里定义了这个功能,你不会这样做。
>
int main()
{
const char phone_book [3] .name [15] =" I Love You!英寸; //我想
改为:
phone_book [3] .name ="我爱你! ;
(BTW,这是一个非常奇怪的名字。)
将字符串分配给char数组但是失败:(
print_entry(3);
system(" PAUSE");
返回0 ;
}
void print_entry(int i)//简单使用
{
cout< ;< phone_book [i] .name<<''''<<< phone_book [i] .number<<''\ n''<<<" I
通过;
}
祝你好运,
Tom
Thomas Tutone写道:
> #include< stdlib。 h>
制作:
#include< cstdlib>
对于所有现实世界的编译器
和那里的情况,这个建议不会自动纠正。
> #include< stdio.h>
这样做:
#include< iostream>
始终。 < stdio.htruly里面没有任何东西可供任何人使用
C ++!
-
Phlip
http://c2.com/cgi/wiki?ZeekLand < ; - 不是博客!!!
似乎没有遇到问题!
Phlip写道:
< blockquote class =post_quotes>
Thomas Tutone写道:
#include< stdlib.h>
这样做:
#include< cstdlib>
对于所有现实编译器
以及那里的情况,该建议不会自动更正。
#include< stdio.h>
这样做:
#include< iostream>
始终。 < stdio.htruly里面没有任何东西可供任何人使用
C ++!
-
Phlip
http://c2.com/cgi/wiki?ZeekLand < ; - 不是博客!
I composed below code but can not pass compiling. Could some one help
this?
------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
using namespace std;
struct Entry{
char name[15];
int number;
};
Entry phone_book[1000];
inline void print_entry(int i) ;
int main()
{
const char phone_book[3].name[15]="I Love You!"; //I want to
assign strings to a char array but fail :(
print_entry(3);
system("PAUSE");
return 0;
}
void print_entry(int i) //simple use
{
cout<<phone_book[i].name<<'' ''<<phone_book[i].number<<''\n''<<"I
Passed";
}
cssh...@gmail.com wrote:I composed below code but can not pass compiling. Could some one help
this?
------------------------------
#include <stdlib.h>Make that:
#include <cstdlib>
#include <stdio.h>Make that:
#include <iostream>
#include <string.h>Make that:
#include <string>
>
using namespace std;
struct Entry{
char name[15];change that to:
string name;
int number;
};
Entry phone_book[1000];
inline void print_entry(int i) ;Delete the word "inline" from the above - it serves no purpose unless
you actually define the function here, which you don''t.
>
int main()
{
const char phone_book[3].name[15]="I Love You!"; //I want toChange that to:
phone_book[3].name="I Love You!";
(BTW, that''s a very strange name.)
assign strings to a char array but fail :(
print_entry(3);
system("PAUSE");
return 0;
}
void print_entry(int i) //simple use
{
cout<<phone_book[i].name<<'' ''<<phone_book[i].number<<''\n''<<"I
Passed";
}Best regards,
Tom
Thomas Tutone wrote:
>#include <stdlib.h>
Make that:
#include <cstdlib>That advice is not automatically correct, for all the real-world compilers
and situations out there.
>#include <stdio.h>
Make that:
#include <iostream>Always. <stdio.htruly has nothing left in it that anyone should use in
C++!
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
seems not hit the problem!
Phlip wrote:Thomas Tutone wrote:
#include <stdlib.h>Make that:
#include <cstdlib>
That advice is not automatically correct, for all the real-world compilers
and situations out there.
#include <stdio.h>Make that:
#include <iostream>
Always. <stdio.htruly has nothing left in it that anyone should use in
C++!
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
这篇关于有人帮忙!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!