C Online Compiler
Example: Basic Student Structure Example in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Basic Student Structure Example #include <stdio.h> #include <string.h> // For strcpy int main() { // Step 1: Define the Student structure struct Student { int studentID; char name[50]; int age; }; // Step 2: Declare a student variable and initialize it struct Student s1; s1.studentID = 101; strcpy(s1.name, "Alice Smith"); s1.age = 20; // Step 3: Print the student's details printf("Student ID: %d\n", s1.studentID); printf("Student Name: %s\n", s1.name); printf("Student Age: %d\n", s1.age); return 0; }
Output
Clear
ADVERTISEMENTS