Showing posts with label C File Handling. Show all posts
Showing posts with label C File Handling. Show all posts

Saturday, October 24, 2026

File Handling in C Language Write Read File in Telugu Part-12 | LearnTechSoft

File Handling in C Language | Full Guide in Telugu

Part-12: Data ni file lo ela save cheyali? - LearnTechSoft

💡 Real Life: Program close cheste data pothundi! Mari save cheyali ante? File lo rayali! Notepad lo data save chesinattu C lo file lo save chestam - Taruvata malli chadavachu!

1. File Handling Steps - 3 Steps

1. fopen()
File Open
2. fprintf() / fscanf()
Read / Write
3. fclose()
File Close

2. File Open Modes - Chala Important

ModeMeaning
"w" - WriteRasthanu - File lekapothe kottha create, unte old delete
"r" - ReadChaduvutanu - File undali compulsory
"a" - AppendKottadi add chestanu - Old data undipotundi
"w+" - Read+WriteRasi chadavachu

3. Write to File - Full Program

#include <stdio.h>

int main() {
    FILE *fp; // File Pointer
    
    // Step 1: Open - "w" mode
    fp = fopen("student.txt", "w");
    
    if(fp == NULL) {
        printf("File open error!");
        return 1;
    }
    
    // Step 2: Write
    fprintf(fp, "Name: Ramesh\n");
    fprintf(fp, "Roll: 101\n");
    fprintf(fp, "Marks: 85.5\n");
    
    // Step 3: Close
    fclose(fp);
    
    printf("Data saved to student.txt successfully!");
    return 0;
}

// Output: student.txt file create ayi data save avtundi

4. Read from File - Full Program

#include <stdio.h>

int main() {
    FILE *fp;
    char data[100];
    
    // Step 1: Open - "r" mode
    fp = fopen("student.txt", "r");
    
    if(fp == NULL) {
        printf("File not found!");
        return 1;
    }
    
    // Step 2: Read - Line by line
    printf("File Data:\n");
    while(fgets(data, 100, fp) != NULL) {
        printf("%s", data);
    }
    
    // Step 3: Close
    fclose(fp);
    
    return 0;
}

5. Real Project Idea

💡 Student Database Project:
Structure + File Handling kalipi - 60 students data ni file lo save cheyachu!
1. Structure - Student details
2. File - "w" tho save
3. File - "r" tho chaduvu - Report card print!
Idhe C Final Project - Interview lo adugutaru!

🎉 CORE C LANGUAGE COMPLETE! - 12 Parts Done!

Next: C Important Programs - Reverse, Palindrome, Prime, Factorial -

Abstraction in Java - Explained in Simple Words with Examples in Telugu | LearnTechSoft Abstraction in Java - Explained in Simpl...