can someone give to me a tip to solve the main()








#include "10_exampr1.cpp"
using namespace std;

void includeName();

char GetString(char *msg);

struct PersonNode{
char name[20];
int age;
};

void includeName()
{
PersonNode newName;
PersonNode newAge;
newName.name = GetString ("Entre Nombre:");
newAge.name = GetString ("Entre Edad:");
PersonNode.name.insert(newName);
PersonNode.age.insert(newAge);

}
char GetString (char *msg)
{
char s[20], i,*destinoItem;
cout<< msg;
cin.get(s,20);
while (cin.get(s[20] && s[81] !='\n');// no permite overflow
destinoItem = new char[stringlen (s)+1];
for (i = 0; destinoItem[i] = toupper(s[i]); i++);
retur destinoItem;

}

main()
{
int option;
// int start = NULL;
do
{

Desplegalinklist <int> theList;
Desplegalinklist <int> theList = theList.FindItemDesp ( );



theList();
cout << endl;
cout << "Elija una opcion: " << endl;
cout << "0. Salida programa." << endl;
cout << "1. Iserta un nodo al inicio de la lista." << endl;
// cout << "2. Inicia Busqueda en el programa." << endl;
// cout << "3. Move the current pointer back one node." << endl;
cout << endl << " >> ";
cin >> option;

switch (option)
{
case 1 : theList.includeName() ; break;
// case 2 : theList.FindItemDesp(); break;
//case 5 :Posicion_anterior_actual ;
}
}
while (option != 0);
};




10_Pruexamprogram1.cpp: In function âvoid includeName()â:
10_Pruexamprogram1.cpp:20: error: incompatible types in assignment of âcharâ to âchar [20]â
10_Pruexamprogram1.cpp:21: error: incompatible types in assignment of âcharâ to âchar [20]â
10_Pruexamprogram1.cpp:22: error: expected unqualified-id before â.â token
10_Pruexamprogram1.cpp:23: error: expected unqualified-id before â.â token
10_Pruexamprogram1.cpp: In function âchar GetString(char*)â:
10_Pruexamprogram1.cpp:28: error: expected initializer before âiâ
10_Pruexamprogram1.cpp:30: error: âsâ was not declared in this scope
10_Pruexamprogram1.cpp:31: error: expected `)' before â;â token
10_Pruexamprogram1.cpp:32: error: âdestinoItemâ was not declared in this scope
10_Pruexamprogram1.cpp:32: error: âstringlenâ was not declared in this scope
10_Pruexamprogram1.cpp:33: error: âiâ was not declared in this scope
10_Pruexamprogram1.cpp:34: error: âreturâ was not declared in this scope
10_Pruexamprogram1.cpp:34: error: expected `;' before âdestinoItemâ
10_Pruexamprogram1.cpp: In function âint main()â:
10_Pruexamprogram1.cpp:46: error: redeclaration of âDesplegalinklist<int> theListâ
10_Pruexamprogram1.cpp:45: error: âDesplegalinklist<int> theListâ previously declared here
10_Pruexamprogram1.cpp:46: error: no matching function for call to âDesplegalinklist<int>::FindItemDesp()â
10_exampr1.cpp:23: note: candidates are: DesplegaType Desplegalinklist<DesplegaType>::FindItemDesp(const DesplegaType&) const [with DesplegaType = int]
10_Pruexamprogram1.cpp:50: error: no match for call to â(Desplegalinklist<int>) ()â
10_Pruexamprogram1.cpp:62: error: âclass Desplegalinklist<int>â has no member named âincludeNameâ

you've delcared theList twice- remove the second desplegalinklist<int>

it also says your function find item doesnt exist nor your include name

its pretty weird that you create theList and then assign it to itself? since i'm not sure what the thelist does i dont know


should be AT LEAST
1
2
3
4
int main()// notice return type of int
{
return 0;// return 0 is pretty standard
}


for more readability

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "10_exampr1.cpp"
using namespace std;

void includeName();

char GetString(char *msg);

struct PersonNode{
char name[20];
int age;
};

void includeName()
{
PersonNode newName;
PersonNode newAge;
newName.name = GetString ("Entre Nombre:");
newAge.name = GetString ("Entre Edad:");
PersonNode.name.insert(newName);
PersonNode.age.insert(newAge);

}
char GetString (char *msg)
{
char s[20], i,*destinoItem;
cout<< msg;
cin.get(s,20);
while (cin.get(s[20] && s[81] !='\n');// no permite overflow
destinoItem = new char[stringlen (s)+1];
for (i = 0; destinoItem[i] = toupper(s[i]); i++);
retur destinoItem;

}

main()
{
int option;
// int start = NULL;
do
{

Desplegalinklist <int> theList;
Desplegalinklist <int> theList = theList.FindItemDesp ( );



theList();
cout << endl;
cout << "Elija una opcion: " << endl;
cout << "0. Salida programa." << endl;
cout << "1. Iserta un nodo al inicio de la lista." << endl;
// cout << "2. Inicia Busqueda en el programa." << endl;
// cout << "3. Move the current pointer back one node." << endl;
cout << endl << " >> ";
cin >> option;

switch (option)
{
case 1 : theList.includeName() ; break;
// case 2 : theList.FindItemDesp(); break;
//case 5 :Posicion_anterior_actual ;
}
}
while (option != 0);
};




10_Pruexamprogram1.cpp: In function âvoid includeName()â:
10_Pruexamprogram1.cpp:20: error: incompatible types in assignment of âcharâ to âchar [20]â
10_Pruexamprogram1.cpp:21: error: incompatible types in assignment of âcharâ to âchar [20]â
10_Pruexamprogram1.cpp:22: error: expected unqualified-id before â.â token
10_Pruexamprogram1.cpp:23: error: expected unqualified-id before â.â token
10_Pruexamprogram1.cpp: In function âchar GetString(char*)â:
10_Pruexamprogram1.cpp:28: error: expected initializer before âiâ
10_Pruexamprogram1.cpp:30: error: âsâ was not declared in this scope
10_Pruexamprogram1.cpp:31: error: expected `)' before â;â token
10_Pruexamprogram1.cpp:32: error: âdestinoItemâ was not declared in this scope
10_Pruexamprogram1.cpp:32: error: âstringlenâ was not declared in this scope
10_Pruexamprogram1.cpp:33: error: âiâ was not declared in this scope
10_Pruexamprogram1.cpp:34: error: âreturâ was not declared in this scope
10_Pruexamprogram1.cpp:34: error: expected `;' before âdestinoItemâ
10_Pruexamprogram1.cpp: In function âint main()â:
10_Pruexamprogram1.cpp:46: error: redeclaration of âDesplegalinklist<int> theListâ
10_Pruexamprogram1.cpp:45: error: âDesplegalinklist<int> theListâ previously declared here
10_Pruexamprogram1.cpp:46: error: no matching function for call to âDesplegalinklist<int>::FindItemDesp()â
10_exampr1.cpp:23: note: candidates are: DesplegaType Desplegalinklist<DesplegaType>::FindItemDesp(const DesplegaType&) const [with DesplegaType = int]
10_Pruexamprogram1.cpp:50: error: no match for call to â(Desplegalinklist<int>) ()â
10_Pruexamprogram1.cpp:62: error: âclass Desplegalinklist<int>â has no member named âincludeNameâ

Last edited on
thank for you recommendations gen1mx6

what about this

10_Pruexamprogram1.cpp:20: error: incompatible types in assignment of âcharâ to âchar [20]â
10_Pruexamprogram1.cpp:21: error: incompatible types in assignment of âcharâ to âchar [20]â
10_Pruexamprogram1.cpp:22: error: expected unqualified-id before â.â token
10_Pruexamprogram1.cpp:23: error: expected unqualified-id before â.â token
10_Pruexamprogram1.cpp: In function âchar GetString(char*)â:

1
2
3
4
5
6
7
8
9
10
11
char GetString (char *msg)
{
char s[20], i,*destinoItem;
cout<< msg;
cin.get(s,20);
while (cin.get(s[20] && s[81] !='\n');// no permite overflow
destinoItem = new char[stringlen (s)+1];
for (i = 0; destinoItem[i] = toupper(s[i]); i++);
retur destinoItem;

}

this seems to be trying to return a char pointer while the actual return type is char. Or would if it were "return"

while (cin.get(s[20] && s[81] !='\n'); doesn't make sense to me. I'm not sure what you were trying to do, but if you want to check two characters for not being equal to '\n', you have to say s[20] != '\n' && s[81] != '\n', though this isn't proper use of cin.get
Last edited on
Topic archived. No new replies allowed.