lost

hi,
i am still a newbee and i am lost... maybe smb has a idea why my function "storage" is ill-designed (in main, line: storage (entryCOUNTmain, entry.name);
does not work. here is my code (x-code platform);
thx a lot,
m

using namespace std;

struct contactDATA
{
string name;
} entry;

template <class contactDATA>

contactDATA storage (contactDATA entryCOUNT, contactDATA userINPUT)

{
char *entryCOPY = new char [userINPUT.length()+1];
strcpy (entryCOPY, userINPUT.c_str());
char matrix[8][userINPUT.length()];
memcpy (matrix[entryCOUNT], entryCOPY, userINPUT.length());

//DATA - readout
for (int x=0; x<userINPUT.length(); x++)
{cout << matrix[entryCOUNT][x] << endl;}
}

int main()

{
int entryCOUNTmain = 0;

cout << "Contact manager \n \n";

cout << "please enter contact... \n";

// DataEntry
cout << "name: \n";
getline(cin, entry.name);
storage (entryCOUNTmain, entry.name);

entryCOUNTmain ++;

cin.ignore(numeric_limits < streamsize> ::max(), '\n' );


return 0;
}


Line 13: You're declaring a templated function which requires two structs by value.

Line 18: You can't declare an array with a non-const bounds.

Line 38: You're try to call an untemplated function. You're also trying to pass different parameter types than the templated function was declared with. (int and string vs. two contactDATA structs).

Suggestion: Get your code working first without using templates, then add templates.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
thx a lot,
guess i have to work bit harder... :)
please do not give up on me and help me again -
cheers m
thx AbstractionAnon,
your line 38 comment saved the day - my code is now fine :)
cheers m
Topic archived. No new replies allowed.