Program Console Vignaankosh.com
Execution Panel
Console is empty.
Student database using pointers 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 <stdlib.h>
#include <string.h>
struct StudentRecord {
int roll;
char name[50];
float marks;
struct StudentRecord *next; // Link to next record
};
void addRecord(struct StudentRecord **head, int roll, char name[], float marks) {
struct StudentRecord *newRecord = (struct StudentRecord*)malloc(sizeof(struct StudentRecord));
newRecord->roll = roll;
strcpy(newRecord->name, name);
newRecord->marks = marks;
newRecord->next = *head; // New node points to current head
*head = newRecord; // Head now points to new node
}
void displayAll(struct StudentRecord *head) {
struct StudentRecord *current = head;
int count = 1;
printf("\n--- Student Database ---\n");
while(current != NULL) {
printf("%d. Roll: %d, Name: %s, Marks: %.2f\n",
count++, current->roll, current->name, current->marks);
current = current->next;
}
}
void freeDatabase(struct StudentRecord *head) {
struct StudentRecord *current = head;
while(current != NULL) {
struct StudentRecord *temp = current;
current = current->next;
free(temp);
}
}
int main() {
struct StudentRecord *database = NULL; // Empty database
// Add records (notice they appear in reverse order due to head insertion)
addRecord(&database, 101, "Alice", 85.5);
addRecord(&database, 102, "Bob", 78.0);
addRecord(&database, 103, "Charlie", 92.5);
displayAll(database);
freeDatabase(database);
return 0;
}