Files
courses/2023_CS50X/algorithms/Source/phonebook0.c
T
2024-11-14 13:11:04 +01:00

26 lines
529 B
C

// 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;
}