English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
void main(){
String x="s";
String y="v" + x;

cout<< y;
getchar();

}

2006-11-05 21:25:01 · 5 answers · asked by Rami 5 in Computers & Internet Programming & Design

i have to wright a sckeleton to calculate the mode but in case of 1,1,1,2,2,2,3 the mode is 1,2

2006-11-05 21:38:22 · update #1

all i need is concatenation

2006-11-05 22:52:21 · update #2

5 answers

Try this ...

#include
using namespace std;

int main ()
{
string x="s";
string y="v" + x;

cout<< y;
getchar();

}

syntax in C and C++ is case sensitive.

String is different than string

also void main() is not correct
main() has to return something to the OS so it has to be an int

IO problems
in C, #include would be correct C++ it is not

need this also...
using namespace std;

2006-11-05 21:51:08 · answer #1 · answered by wizzie b 3 · 1 1

There is NO 'String' data type in C++. You have probably switched over from Java. C++ treats a string as an array of characters. And the getchar() function is in stdio.h and not in iostream.h.
The program will be as follows:
#include
void main()
{
char x='s';
char y[2];
y[0]='v';
y[1]=x;

cout< }

2006-11-05 21:32:58 · answer #2 · answered by Anonymous · 0 2

wizzie b has answered you correctly, but one thing they may have missed. Some compilers will include string automatically, whereas some do not. Also, some compilers do not have string at all. If that is the case, then you may have to use Ashutosh answer concerning char arrays.

If your compiler has the string.h file, then you can include it like this.

#include

2006-11-07 01:21:28 · answer #3 · answered by Mark aka jack573 7 · 0 0

i didnt quite get your question, are you trying to implement multiple outputs. You need to do in a while loop
eg.
while(condition == true)
{
cin >> a;
cout << a;
}
Write some condition to exit the while loop

2006-11-05 22:02:10 · answer #4 · answered by mcubea 2 · 0 2

is that String or string?
whats the output you get?

2006-11-05 21:33:18 · answer #5 · answered by nukeu666 3 · 0 0

fedest.com, questions and answers