Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please fix the errors. or tell me how to. The code is not running. The language is C++. Coded in visual studio. Urgently needed. Thank

Please fix the errors. or tell me how to. The code is not running. The language is C++. Coded in visual studio. Urgently needed. Thank you.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

IVIIscella MKEOUSL #include #include #include using namespace std; // FOR STORING CONTACT INFO struct Node { int key=0; string name; string primary_contact; string secondary_contact; string address; Node* next; // POINTER TO DIRECT TO NEXT NODE // TO DO FUNCTIONS ON LINKEDLIST class linkedlist { public: linkedlist() // CONSTRUCTOR 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 5% headptr = 0; FUNCTION TO ADD CONTACT TO LINKED LIST. void addcontact(int pkey, string pname, string pricontact, string seccontact, string paddress) { Node* ptrnew = new Node; ptrnew->key = pkey; ptrnew->primary_contact = pricontact; ptrnew->secondary_contact = seccontact; ptrnew->address = paddress; ptrnew->name = pname; ptrnew->next = 0; Node* ptr Temp = headptr; PLACING NODE if (headptr == 0) // { headptr = ptrnew; return: No issues found MUNCUL 40 41 headptr = ptrnew; return; 42 43 44 while (ptrTemp->next != 0) ptrTemp = ptr Temp->next; 45 46 47 48 49 50 ptrTemp->next = ptrnew; 51 FUNCTION TO DELETE CONTACT FROM LINKED LIST. bool deletecontact(string pname) { Node* ptrTemp = headptr, * ptr Previous; int count = 0; string contact; FINDING CONTACT BY NAME TO DELETE 52 53 54 55 56 57 58 59 60 61 while (ptrTemp != 0) // { if (ptrTemp->name == pname) count++; cout name key primary_contact secondary_contact address next; 66 67 68 if (count == 0) // ERROR IF NO CONTACT FOUND. cout > contact; 80 Node* ptrnew = headptr, * previousptr; // DELETING NODE while (ntrnew != 0 && (ntrnew->name != nname || ntrnew->primary contact != contact)) No issues found 5 % Node* ptrnew = headptr, * previousptr; // DELETING NODE while (ptrnew != 0 && (ptrnew->name != pname || ptrnew->primary_contact != contact)) { previousptr = ptrnew; ptrnew = ptrnew->next; if (ptrnew == headptr) headptr = headptr->next; else { previousptr->next = ptrnew->next; cout name == pname) cout name key primary_contact secondary_contact address next; 112 113 114 115 if (check == 0) // ERRPR IF NO CONTACT FOUND. { cout key name primary_contact "\t" tempptr->secondary_contact "\t" tempptr->address; tempptr = tempptr->next; -linkedlist() // DESTRUCTOR 129 Node* previousptr; while (headptr != NULL) previousptr = headptr; headptr = headptr->next; delete previousptr; 130 131 132 133 134 135 136 137 138 139 140 141 142 } private: Node* headptr; }; 143 // HASHTABLE CLASS class hashTableList { public: hashTablelist() // CONSTRUCTOR 144 145 146 147 148 149 150 151 152 153 int key; string name, pricontact, seccontact, address; ifstream file; // READING DATA FROM FILE file.open("CMS.txt"); while (!file.eof()) 154 file >> key >> name >> pricontact >> seccontact >> address; array[key] .addcontact(key, name, pricontact, seccontact, address); file.close(); 155 156 157 158 159 25 % No issues found file.close(); } Il Function to generate key int hashTableKey(string name) { int x = name.length() % 20; return x; 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 95 % void addinfo) // FUNCTION TO ADD CONTACTS TO FILE { string name, pricontact, seccontact, address; cout > x; if (x == 1) 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 95 % system("CLS"); cms.addinfo; continue; if (x == 2) cms.deleteinfo; system("CLS"); continue; if (x == 3) { cms.searchinfo; system("CLS"); continue; - else if (x == 4) flag = false; system("CLS");}}}return 0; } No issues found Project File Line prrrractice PRRRRACTICE.CPP 18 prrrractice PRRRRACTICE.CPP 87 prrrractice PRRRRACTICE.CPP 90 Code Description A C26495 Variable 'Node:next' is uninitialized. Always initialize a member variable (type.6). C28182 Dereferencing NULL pointer. "headptr' contains the same NULL value as *ptrTemp' did. DA C28182 Dereferencing NULL pointer. 'ptrnew' contains the same NULL value as *ptrTemp' did. X C3867 "hashTableList::addinfo: non-standard syntax; use '&' to create a pointer to member X C3867 "hashTableList::deleteinfo : non-standard syntax; use '&' to create a pointer to member "hashTableList::searchinfo: non-standard syntax; use '&' to create a X C3867 pointer to member prrrractice prrrractice.cpp 222 prrrractice prrrractice.cpp 227 prrrractice prrrractice.cpp 233

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems On GPUs In Databases

Authors: Johns Paul ,Shengliang Lu ,Bingsheng He

1st Edition

1680838482, 978-1680838480

More Books

Students also viewed these Databases questions