Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
phonebook
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9631412
phonebook
Commits
8f60c6dc
Commit
8f60c6dc
authored
Mar 18, 2020
by
Ardavan_Roozkhosh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c codes and executable files
parents
Pipeline
#2742
failed with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
318 additions
and
0 deletions
+318
-0
PB.cbp
PB.cbp
+44
-0
PB.depend
PB.depend
+6
-0
PB.layout
PB.layout
+9
-0
main.c
main.c
+259
-0
No files found.
PB.cbp
0 → 100644
View file @
8f60c6dc
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion
major=
"1"
minor=
"6"
/>
<Project>
<Option
title=
"PB"
/>
<Option
pch_mode=
"2"
/>
<Option
compiler=
"gcc"
/>
<Build>
<Target
title=
"Debug"
>
<Option
output=
"bin/Debug/PB"
prefix_auto=
"1"
extension_auto=
"1"
/>
<Option
object_output=
"obj/Debug/"
/>
<Option
type=
"1"
/>
<Option
compiler=
"gcc"
/>
<Compiler>
<Add
option=
"-g"
/>
</Compiler>
</Target>
<Target
title=
"Release"
>
<Option
output=
"bin/Release/PB"
prefix_auto=
"1"
extension_auto=
"1"
/>
<Option
object_output=
"obj/Release/"
/>
<Option
type=
"1"
/>
<Option
compiler=
"gcc"
/>
<Compiler>
<Add
option=
"-O2"
/>
</Compiler>
<Linker>
<Add
option=
"-s"
/>
</Linker>
</Target>
</Build>
<Compiler>
<Add
option=
"-Wall"
/>
</Compiler>
<Unit
filename=
"main.c"
>
<Option
compilerVar=
"CC"
/>
</Unit>
<Extensions>
<code_completion
/>
<envvars
/>
<debugger
/>
<lib_finder
disable_auto=
"1"
/>
</Extensions>
</Project>
</CodeBlocks_project_file>
PB.depend
0 → 100644
View file @
8f60c6dc
# depslib dependency file v1.0
1516698382 source:c:\users\ardavan\desktop\coding\phone book\pb\main.c
<stdio.h>
<stdlib.h>
<string.h>
PB.layout
0 → 100644
View file @
8f60c6dc
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget
name=
"Debug"
/>
<File
name=
"main.c"
open=
"1"
top=
"1"
tabpos=
"1"
split=
"0"
active=
"1"
splitpos=
"0"
zoom_1=
"0"
zoom_2=
"0"
>
<Cursor>
<Cursor1
position=
"167"
topLine=
"0"
/>
</Cursor>
</File>
</CodeBlocks_layout_file>
main.c
0 → 100644
View file @
8f60c6dc
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef
struct
PhoneBook_Contacts
{
char
FirstName
[
20
];
char
LastName
[
20
];
char
PhoneNumber
[
20
];
}
phone
;
void
AddEntry
(
phone
*
);
void
DeleteEntry
(
phone
*
);
void
PrintEntry
(
phone
*
);
int
counter
=
0
;
int
main
(
void
)
{
phone
*
phonebook
;
phonebook
=
(
phone
*
)
malloc
(
sizeof
(
phone
)
*
1
);
int
iSelection
=
0
;
if
(
phonebook
==
NULL
)
{
printf
(
"Out of Memory. The program will now exit"
);
return
1
;
}
else
{}
while
(
iSelection
<=
4
)
{
printf
(
"
\n\t
Phonebook Menu"
);
printf
(
"
\n\n\t
(1).....> Add Contact"
);
printf
(
"
\n\t
(2)-----> Delete Contact"
);
printf
(
"
\n\t
(3).....> Display All Contacts"
);
printf
(
"
\n\t
(4)-----> Exit The App"
);
printf
(
"
\n\n
please select your desired option "
);
scanf
(
"%d"
,
&
iSelection
);
if
(
iSelection
==
1
)
{
AddEntry
(
phonebook
);
}
if
(
iSelection
==
2
)
{
DeleteEntry
(
phonebook
);
}
if
(
iSelection
==
3
)
{
PrintEntry
(
phonebook
);
}
if
(
iSelection
==
4
)
{
printf
(
"The Phonebook will now exit."
);
system
(
"cls"
);
free
(
phonebook
);
return
0
;
}
}
}
void
AddEntry
(
phone
*
phonebook
)
{
counter
++
;
realloc
(
phonebook
,
sizeof
(
phone
));
printf
(
"
\n
First Name: "
);
scanf
(
"%s"
,
phonebook
[
counter
-
1
].
FirstName
);
printf
(
"Last Name: "
);
scanf
(
"%s"
,
phonebook
[
counter
-
1
].
LastName
);
printf
(
"Phone Number :"
);
scanf
(
"%s"
,
phonebook
[
counter
-
1
].
PhoneNumber
);
printf
(
"
\n\t
Contact successfully added to Phonebook
\n
"
);
}
void
DeleteEntry
(
phone
*
phonebook
)
{
int
x
=
0
;
char
deleteFirstName
[
20
];
char
deleteLastName
[
20
];
char
nullStr
[
20
]
=
{
"
\0
"
};
printf
(
"
\n
First name: "
);
scanf
(
"%s"
,
deleteFirstName
);
printf
(
"Last name: "
);
scanf
(
"%s"
,
deleteLastName
);
for
(
x
=
0
;
x
<
counter
;
x
++
)
{
if
(
strcmp
(
deleteFirstName
,
phonebook
[
x
].
FirstName
)
==
0
)
{
for
(
x
=
0
;
x
<
counter
;
x
++
)
{
if
(
strcmp
(
deleteLastName
,
phonebook
[
x
].
LastName
)
==
0
)
{
strcpy
(
phonebook
[
x
].
FirstName
,
nullStr
);
strcpy
(
phonebook
[
x
].
LastName
,
nullStr
);
strcpy
(
phonebook
[
x
].
PhoneNumber
,
nullStr
);
}
else
{
printf
(
"Invalid Entry."
);
}
}
}
}
counter
--
;
printf
(
"Contact deleted from the phonebook.
\n\n
"
);
}
void
PrintEntry
(
phone
*
phonebook
)
{
int
x
=
0
;
printf
(
"
\n
Phonebook Contacts:
\n\n
"
);
for
(
x
=
0
;
x
<
counter
;
x
++
)
{
printf
(
"
\n
(%d)
\n
"
,
x
+
1
);
printf
(
"Name: %s %s
\n
"
,
phonebook
[
x
].
FirstName
,
phonebook
[
x
].
LastName
);
printf
(
"Number: %s
\n
"
,
phonebook
[
x
].
PhoneNumber
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment