Program Console Vignaankosh.com
Execution Panel
Console is empty.
Update records using function is an interactive C dry run visualizer from the Struct Functions Pointers programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
#include <stdio.h>
#include <string.h>
struct Contact {
long long phone;
char name[50];
char email[50];
};
int updateContact(struct Contact contacts[], int size, long long phone, char newName[], char newEmail[]) {
for(int i = 0; i < size; i++) {
if(contacts[i].phone == phone) {
strcpy(contacts[i].name, newName);
strcpy(contacts[i].email, newEmail);
return 1;
}
}
return 0;
}
void displayContacts(struct Contact contacts[], int size) {
printf("\n%-15s %-20s %-30s\n", "Phone", "Name", "Email");
printf("--------------------------------------------------------\n");
for(int i = 0; i < size; i++) {
printf("%-15lld %-20s %-30s\n",
contacts[i].phone, contacts[i].name, contacts[i].email);
}
}
int main() {
struct Contact contacts[3] = {
{9876543210, "Alice Brown", "alice@email.com"},
{9876543211, "Bob Wilson", "bob@email.com"},
{9876543212, "Charlie Davis", "charlie@email.com"}
};
printf("Original Contacts:");
displayContacts(contacts, 3);
if(updateContact(contacts, 3, 9876543211, "Robert Wilson", "robert@email.com")) {
printf("\nContact updated successfully!");
} else {
printf("\nContact not found!");
}
printf("\n\nUpdated Contacts:");
displayContacts(contacts, 3);
return 0;
}