Initial commit with cleaned history
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// Implements a phone book without structs
|
||||
|
||||
#include <cs50.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Arrays of strings
|
||||
string names[] = {"Carter", "David"};
|
||||
string numbers[] = {"+1-617-495-1000", "+1-949-468-2750"};
|
||||
|
||||
// Search for name
|
||||
string name = get_string("Name: ");
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (strcmp(names[i], name) == 0)
|
||||
{
|
||||
printf("Found %s\n", numbers[i]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
printf("Not found\n");
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user