Skip to content

Commit 8a54a37

Browse files
authored
Merge branch 'main' into main
2 parents 7753b52 + 22c11df commit 8a54a37

File tree

10 files changed

+1164
-1
lines changed

10 files changed

+1164
-1
lines changed

.vscode/settings.json

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,73 @@
11
{
22
"C_Cpp.errorSquiggles": "disabled",
3-
"cmake.sourceDirectory": "C:/Users/shiva/Desktop/Projects/cppM/CPP_Mini_Projects/Src/Password_Generator"
3+
"files.associations": {
4+
"array": "cpp",
5+
"atomic": "cpp",
6+
"bitset": "cpp",
7+
"cctype": "cpp",
8+
"cfenv": "cpp",
9+
"chrono": "cpp",
10+
"cinttypes": "cpp",
11+
"clocale": "cpp",
12+
"cmath": "cpp",
13+
"codecvt": "cpp",
14+
"complex": "cpp",
15+
"condition_variable": "cpp",
16+
"csetjmp": "cpp",
17+
"csignal": "cpp",
18+
"cstdarg": "cpp",
19+
"cstddef": "cpp",
20+
"cstdint": "cpp",
21+
"cstdio": "cpp",
22+
"cstdlib": "cpp",
23+
"cstring": "cpp",
24+
"ctime": "cpp",
25+
"cuchar": "cpp",
26+
"cwchar": "cpp",
27+
"cwctype": "cpp",
28+
"deque": "cpp",
29+
"forward_list": "cpp",
30+
"list": "cpp",
31+
"unordered_map": "cpp",
32+
"unordered_set": "cpp",
33+
"vector": "cpp",
34+
"exception": "cpp",
35+
"algorithm": "cpp",
36+
"functional": "cpp",
37+
"iterator": "cpp",
38+
"map": "cpp",
39+
"memory": "cpp",
40+
"memory_resource": "cpp",
41+
"numeric": "cpp",
42+
"random": "cpp",
43+
"ratio": "cpp",
44+
"regex": "cpp",
45+
"set": "cpp",
46+
"string": "cpp",
47+
"string_view": "cpp",
48+
"system_error": "cpp",
49+
"tuple": "cpp",
50+
"type_traits": "cpp",
51+
"utility": "cpp",
52+
"fstream": "cpp",
53+
"future": "cpp",
54+
"initializer_list": "cpp",
55+
"iomanip": "cpp",
56+
"iosfwd": "cpp",
57+
"iostream": "cpp",
58+
"istream": "cpp",
59+
"limits": "cpp",
60+
"mutex": "cpp",
61+
"new": "cpp",
62+
"ostream": "cpp",
63+
"scoped_allocator": "cpp",
64+
"shared_mutex": "cpp",
65+
"sstream": "cpp",
66+
"stdexcept": "cpp",
67+
"streambuf": "cpp",
68+
"thread": "cpp",
69+
"typeindex": "cpp",
70+
"typeinfo": "cpp",
71+
"valarray": "cpp"
72+
}
473
}

Src/Contact_Managment_System/a.exe

60.1 KB
Binary file not shown.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#include <iostream>
2+
#include <fstream>
3+
#include <iomanip>
4+
#include <string>
5+
using namespace std;
6+
class ContactManager {
7+
private:
8+
string phoneNo, name, address, description;
9+
fstream file;
10+
11+
public:
12+
void menu();
13+
void addContact();
14+
void showAll();
15+
void searchContact();
16+
};
17+
// Function to display menu
18+
void ContactManager::menu() {
19+
char choice;
20+
do {
21+
system("cls");
22+
cout << " # CONTACT MANAGEMENT APP \n";
23+
cout << "________________________________\n";
24+
cout << "1 → Add Contact\n";
25+
cout << "2 → Show All Contacts\n";
26+
cout << "3 → Search Contact\n";
27+
cout << "0 → Exit\n";
28+
cout << "________________________________\n";
29+
cout << "Enter your choice: ";
30+
cin >> choice;
31+
cin.ignore();
32+
33+
switch (choice) {
34+
case '1':
35+
addContact();
36+
break;
37+
case '2':
38+
showAll();
39+
break;
40+
case '3':
41+
searchContact();
42+
break;
43+
case '0':
44+
cout << "\nExiting the program... Goodbye!\n";
45+
break;
46+
default:
47+
cout << "\nInvalid choice! Please try again.\n";
48+
}
49+
50+
if (choice != '0') {
51+
cout << "\nPress Enter to continue...";
52+
cin.get();
53+
}
54+
55+
} while (choice != '0');
56+
}
57+
// Function to add new contact
58+
void ContactManager::addContact() {
59+
cout << "\nEnter Phone Number: ";
60+
getline(cin, phoneNo);
61+
cout << "Enter Name: ";
62+
getline(cin, name);
63+
cout << "Enter Address: ";
64+
getline(cin, address);
65+
cout << "Enter Description: ";
66+
getline(cin, description);
67+
68+
file.open("contacts.csv", ios::out | ios::app);
69+
if (!file){
70+
cerr<<"Error opening file for writing!\n";
71+
return;
72+
}
73+
74+
file << phoneNo << "," << name << "," << address << "," << description << "\n";
75+
file.close();
76+
77+
cout << "\nContact added successfully!";
78+
}
79+
// Function to display all contacts
80+
void ContactManager::showAll() {
81+
file.open("contacts.csv", ios::in);
82+
if (!file) {
83+
cerr << "Error opening file! No data found.\n";
84+
return;
85+
}
86+
87+
cout << "\n CONTACT LIST \n";
88+
cout << left << setw(15) << "Phone No"
89+
<< setw(20) << "Name"
90+
<< setw(25) << "Address"
91+
<< setw(30) << "Description" << endl;
92+
cout << "________________________________\n";
93+
94+
bool found = false;
95+
while(getline(file, phoneNo, ',')){
96+
getline(file, name, ',');
97+
getline(file, address, ',');
98+
getline(file, description, '\n');
99+
100+
cout << left << setw(15) << phoneNo
101+
<< setw(20) << name
102+
<< setw(25) << address
103+
<< setw(30) << description << endl;
104+
105+
found = true;
106+
}
107+
if(!found)
108+
cout << "\nNo contacts found.\n";
109+
110+
file.close();
111+
}
112+
// Function to search a contact by phone number
113+
void ContactManager::searchContact() {
114+
cout << "\nEnter Phone Number to Search: ";
115+
string searchPhone;
116+
getline(cin, searchPhone);
117+
118+
file.open("contacts.csv", ios::in);
119+
if (!file) {
120+
cerr << "Error opening file! No data found.\n";
121+
return;
122+
}
123+
124+
bool found = false;
125+
while (getline(file, phoneNo, ',')) {
126+
getline(file, name, ',');
127+
getline(file, address, ',');
128+
getline(file, description, '\n');
129+
130+
if (phoneNo == searchPhone) {
131+
cout << "\n Contact Found!\n";
132+
cout << "Phone Number: " << phoneNo << endl;
133+
cout << "Name: " << name << endl;
134+
cout << "Address: " << address << endl;
135+
cout << "Description: " << description << endl;
136+
found = true;
137+
break;
138+
}
139+
}
140+
141+
if (!found)
142+
cout << "\n No contact found with that phone number.\n";
143+
144+
file.close();
145+
}
146+
147+
int main() {
148+
ContactManager app;
149+
app.menu();
150+
return 0;
151+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
54545454,indr,jodhpur,hi

0 commit comments

Comments
 (0)