What will it do?

X

Xohaib

Let i have a 2d character array.


=====================
char array[5][25];
array[2]="\0";
for (int i=0; i<5; i++)
{
cout<<"Enter the value ";
cin>>array;
}
for (int j=0; j<5; j++)
{
cout<<array[j]<<endl;
}




=======================
will it get input in array[2] ?





i have done this but it gave me error to debug....


please help;



and how can i sort more than one 2D arrays??


i tried but it sort only one array but it also gave me error to
debug...




Please help ..........



REGRADS:
Xohaib
 
A

asterisc

Let i have a 2d character array.

=====================
char array[5][25];
array[2]="\0";
for (int i=0; i<5; i++)
{
cout<<"Enter the value ";
cin>>array;}

for (int j=0; j<5; j++)
{
cout<<array[j]<<endl;

}

=======================
will it get input in array[2] ?

i have done this but it gave me error to debug....

please help;

and how can i sort more than one 2D arrays??

i tried but it sort only one array but it also gave me error to
debug...

Please help ..........

REGRADS:
Xohaib


What are you trying to do doesn't make any sense.

What does it mean "to sort more than one 2D arrays" ?
 
R

Rolf Magnus

Xohaib said:
Let i have a 2d character array.


=====================
char array[5][25];

Better use a vector of strings instead of an array of arrays of raw
characters.
array[2]="\0";

The above line should not compile. You can't assign to arrays.
for (int i=0; i<5; i++)
{
cout<<"Enter the value ";
cin>>array;


What happens if the user enters more than 24 characters?
}
for (int j=0; j<5; j++)
{
cout<<array[j]<<endl;
}




=======================
will it get input in array[2] ?

That depends. If the stream goes into error state, you won't get a valid C
style string for all following elements.
and how can i sort more than one 2D arrays??

Not sure what you mean by that.
i tried but it sort only one array but it also gave me error to
debug...

How did you try? What was the error? Where did you get it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,186
Messages
2,570,998
Members
47,587
Latest member
JohnetteTa

Latest Threads

Top