c programming ,storing phone number | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 3

c programming ,storing phone number

Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each queried, print the associated entry from your phone book on a new line in the form name=phoneNumber; if an entry for is not found, print Not found instead.Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown num.

24th Apr 2018, 7:07 AM
Nitesh Yadav
Nitesh Yadav - avatar
2 Réponses
0
And this is your work not our... If get stuck on some problem open a discussion but you cannot get your works maded from others
24th Apr 2018, 11:48 AM
KrOW
KrOW - avatar
0
* You can create a struct named 'contact' and include 2 parameters: - 'name' and - 'number.' typedef struct { char name [50]; char number[16]; } contact_t; * And then create an array of struct 'contact', you can name the array 'phoneBook'. contact_t phoneBook [MAX_NUM_ENTRIES]; * Now you need to fill you phoneBook. phoneBook[0].name = "Petter Pan" phoneBook[0].number = "+3374536969" phoneBook[1].name = "Test Name" phoneBook[1].number = "+3355555555" * Once you have the phoneBook filled you can find contacts by name or by number: // Find by name: String nameToSeek = "Petter Pan"; for(int i= 0; i < MAX_NUM_ENTRIES; i++){ if (strcmp(nameToSeek,phoneBook[i].name) == 0) printf("The phone number of %s is %s", nameToSeek, phoneBook[i].number); } * Try the rest by your own :) . You can ask for any specific question.
24th Apr 2018, 12:13 PM
J Domingo Jiménez J
J Domingo Jiménez J - avatar