帮助Lvalue需要问题 [英] Help Problem with Lvalue required

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

问题描述

你好我有我的代码,但有问题char = char


#include< conio.h>

#include< stdio。 h>

struct Pate {

char Nome [20];

};


main ()

{

char lettere [3] = {''A'',''P'',''Z''};

Pate articoli [3] = {{" gli"},{" un"},{" una"}};

Pate

preposizioni [10] = {{"二"},{" A"},{" DA"},{"在"},{" CON"},{"苏"},{"每" },{" tra"},

{" fra"}};


char text [5000],pat [100],te [ 1];

int no,count,pos [20],i;

clrscr();

cout<<"" \\ n \ n插入文字:" ;;

得到(文字);


cout<<"插入一个字符串:" ;;

//得到(拍);

for(i = 0; i< 3; i ++){

// pat = lettere [i] ; //错误

pat = articoli [1] .Nome; //错误

}

}

解决方案

Maurizio Porcu写道:

你好,我有我的代码,但有问题char = char


不,你有char [] = char []的问题。你可能会发现它很容易使用std :: string。

#include< conio.h>
#include< stdio。 h取代;


conio.h不标准。 stdio.h适用于C. C ++应该使用< cstdio>或者

更好< iostream> ;.

struct Pate {
char Nome [20];
};


怎么样


typedef char Nome [20];


或更好:


#include< string>

main()


int main( )

{
char lettere [3] = {''A'',''P'',''Z''};
Pate articoli [3] = {{" gli"},{" un"},{" una"}};
Pate
preposizioni [10] = {{" di"},{" a" },{" DA"},{"在"},{" CON"},{"苏"},{"每" },{" tra"},
{" fra"}};


将这些都设为const。

char text [5000],pat [100],te [1];


一个数组?

int no,count,pos [20],i;
clrscr();


非标准。

cout<<" \ n \ n插入文字:" ;;
获取(文字);


你在混合cout(当你实际上并没有包括< iostream>!)和

得到?喜欢cin得到。

cout<<"插入一个字符串:" ;;
//获取(pat);
for(i = 0; i< 3 ; i ++){
// pat = lettere [i]; //错误
pat = articoli [1] .Nome; //错误


使用std :: string来获得这种便利。否则,你需要

来包含< string.h>或< cstring>得到strcpy。

}


返回0;

}




干杯! --M


Maurizio Porcu写道:

你好,我有这个我的代码,但有char = char $ b $的问题b

不,你不是。你有char [] = char []的问题。

#include< conio.h>
#include< stdio.h>
struct Pate {
char Nome [20];
};

main()


int main()

{
char lettere [3] = {''A'',''P'',''Z''};
Pate articoli [3] = {{" gli"},{" ; un"},{" una"}};
Pate
preposizioni [10] = {{" di"},{" a"},{" da"},{ "在"},{" CON"},{"苏"},{"每" },{" tra"},
{" fra"}};

char text [5000],pat [100],te [1];
int no,count,pos [20],i;
clrscr();
cout<<" \ n \ n插入文字:" ;;
获取(文字);

cout<<"插入一个字符串:" ;;
//获取(pat);
for(i = 0; i< 3; i ++){
// pat = lettere [i]; //错误
pat = articoli [1] .Nome; //错误


数组不能用C ++分配

}
}




不要使用字符数组,请使用''std :: string''。


V


给我推荐pelase

i学生并且需要解决这个问题


" Victor Bazarov" <五******** @ comAcast.net> ha scritto nel messaggio

新闻:oT ******************* @ newsread1.mlpsca01.us.t o.verio.net ...

Maurizio Porcu写道:

你好我有这个我的代码但是有问题char = char



不,你不要T。你有char [] = char []的问题。

#include< conio.h>
#include< stdio.h>
struct Pate {
char Nome [20];
};

main()



int main()
< blockquote class =post_quotes> {
char lettere [3] = {''A'',''P'',''Z''};
Pate articoli [3] = {{ " gli"},{" un"},{" una"}};
Pate

preposizioni [10] = {{" di"},{"一个"},{" DA"},{"在"},{" CON"},{"苏"},{"每" },{" tra"},{" fra"}};

char text [5000],pat [100],te [1];
int no,count, pos [20],i;
clrscr();
cout<<" \ n \ n插入文字:" ;;
获取(文字);

cout<<"插入一个字符串:" ;;
//获取(pat);
for(i = 0; i< 3; i ++){
//轻拍=莱泰雷[I]; //错误
pat = articoli [1] .Nome; //错误



数组不能在C ++中分配

}
}


不要使用字符数组,使用''std :: string''。

V



Hello i have this my code but have problem with char=char

# include <conio.h>
# include <stdio.h>
struct Pate {
char Nome[20];
};

main()
{
char lettere[3] = { ''A'',''P'',''Z''};
Pate articoli[3]={{"gli"},{"un"},{"una"}};
Pate
preposizioni[10]={{"di"},{"a"},{"da"},{"in"},{"con"},{"su"},{"per" },{"tra"},
{"fra"}};

char text[5000],pat[100], te[1];
int no,count,pos[20],i;
clrscr();
cout<<"\n\nInsert text:";
gets(text);

cout<<"Insert one string:";
// gets(pat);
for (i=0;i<3;i++){
//pat=lettere[i]; //error
pat=articoli[1].Nome; //error
}
}

解决方案

Maurizio Porcu wrote:

Hello i have this my code but have problem with char=char
No, you have a problem with char[] = char[]. You''ll probably find it
easier to work with std::string.

# include <conio.h>
# include <stdio.h>
conio.h is not standard. stdio.h is for C. C++ should use <cstdio> or
better <iostream>.
struct Pate {
char Nome[20];
};
How about:

typedef char Nome[20];

or better:

#include <string>

main()
int main()
{
char lettere[3] = { ''A'',''P'',''Z''};
Pate articoli[3]={{"gli"},{"un"},{"una"}};
Pate
preposizioni[10]={{"di"},{"a"},{"da"},{"in"},{"con"},{"su"},{"per" },{"tra"},
{"fra"}};
Make these all const.

char text[5000],pat[100], te[1];
An array of one?
int no,count,pos[20],i;
clrscr();
Non-standard.
cout<<"\n\nInsert text:";
gets(text);
You''re mixing cout (when you didn''t actually include <iostream>!) and
gets? Prefer cin to gets.

cout<<"Insert one string:";
// gets(pat);
for (i=0;i<3;i++){
//pat=lettere[i]; //error
pat=articoli[1].Nome; //error
Use std::string to get this type of convenience. Otherwise, you''ll need
to include <string.h> or <cstring> to get strcpy.
}
return 0;
}



Cheers! --M


Maurizio Porcu wrote:

Hello i have this my code but have problem with char=char
No, you don''t. You have a problem with char[]=char[].
# include <conio.h>
# include <stdio.h>
struct Pate {
char Nome[20];
};

main()
int main()
{
char lettere[3] = { ''A'',''P'',''Z''};
Pate articoli[3]={{"gli"},{"un"},{"una"}};
Pate
preposizioni[10]={{"di"},{"a"},{"da"},{"in"},{"con"},{"su"},{"per" },{"tra"},
{"fra"}};

char text[5000],pat[100], te[1];
int no,count,pos[20],i;
clrscr();
cout<<"\n\nInsert text:";
gets(text);

cout<<"Insert one string:";
// gets(pat);
for (i=0;i<3;i++){
//pat=lettere[i]; //error
pat=articoli[1].Nome; //error
Arrays are not assignable in C++
}
}



Don''t use character arrays, use ''std::string''.

V


give me recommend pelase
i student and have need to solve this problem

"Victor Bazarov" <v.********@comAcast.net> ha scritto nel messaggio
news:oT*******************@newsread1.mlpsca01.us.t o.verio.net...

Maurizio Porcu wrote:

Hello i have this my code but have problem with char=char



No, you don''t. You have a problem with char[]=char[].

# include <conio.h>
# include <stdio.h>
struct Pate {
char Nome[20];
};

main()



int main()

{
char lettere[3] = { ''A'',''P'',''Z''};
Pate articoli[3]={{"gli"},{"un"},{"una"}};
Pate
preposizioni[10]={{"di"},{"a"},{"da"},{"in"},{"con"},{"su"},{"per" },{"tra"}, {"fra"}};

char text[5000],pat[100], te[1];
int no,count,pos[20],i;
clrscr();
cout<<"\n\nInsert text:";
gets(text);

cout<<"Insert one string:";
// gets(pat);
for (i=0;i<3;i++){
//pat=lettere[i]; //error
pat=articoli[1].Nome; //error



Arrays are not assignable in C++

}
}



Don''t use character arrays, use ''std::string''.

V



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

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