function does not take 3 arguments?
Mar 9, 2008 at 8:18pm UTC
Hi,
I've made a struct and I would like to put it in a function, but when I call the function i get the error: "function does not take 3 arguments".
This is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*--------------------------------*/
#include <conio.h>
#include <iostream>
#include <string>
using namespace std;
struct test{string text; string text2; string text3;} data;
void TEXT(test data)
{
cout << "This is the texts: " << data.text << data.text2 << data.tekst3 << endl;
}
int main()
{
TEXT("test1" , "test2" , "test3" );
getch();
return 0;
}
/*--------------------------*/
Best regards
Malik, DK
Mar 9, 2008 at 9:05pm UTC
yo Malik
Well the problems is:
your TEXT function accepts a ***struct*** as argument and not 3 strings;
off topic: if conio.h is there just for getch() you are better off with cin.get() from the <iostream> header you get the same "press any key to continue..." effect.
i think what your trying to do is this:
1 2 3 4 5 6 7 8 9 10
int main()
{
data.text = "test1" ;
data.text2 = "test2" ;
data.text3 = "test3" ;
TEXT(data);
cin.get();
return 0;
}
Jeff
Last edited on Mar 9, 2008 at 9:09pm UTC
Mar 10, 2008 at 5:28am UTC
Thank you alot Jeff :) and thanks for the tip about cin.get()
Topic archived. No new replies allowed.