Posts

C Programming Tutorials – Complete Guide from Basics to Advanced

Welcome to C Tutorials MP , a learning resource for students who want to learn C programming step by step. Explore the topics below, read the explanations, practise programs, and strengthen your programming fundamentals. How to use this guide: Start with Section 1 and continue in order. Click any topic to open its dedicated tutorial. We will keep this index updated as more lessons are added. 1. Introduction to C Programming Introduction to C Programming History and Features of C Applications and Advantages of C Structure of a C Program Writing and Executing Your First C Program Compiler, Interpreter and IDE 2. Tokens, Variables and Data Types Tokens in C Keywords and Identifiers Variables and Constants Data Types in C Declaration and Initialization of Variables Type Conversion and Type Casting 3. Input, Output and Operators printf() and scanf() Functions Operators in C Arithmetic and Relational Operators Logical and Assignment Operators Increment and Decrement Operators Operator Prece...

Formatted File Input and Output in C Using fscanf() and fprintf()

Introduction to Formatted File Input and Output In C language, the fscanf() and fprintf() functions are used to read and write formatted data in a file. These functions work similarly to scanf() and printf() , but instead of reading from the keyboard or displaying output on the screen, they perform input and output operations on files. C language में fscanf() और fprintf() functions का उपयोग किसी file में formatted data को read और write करने के लिए किया जाता है। ये functions scanf() और printf() की तरह कार्य करते हैं, लेकिन keyboard से input लेने या screen पर output दिखाने के बजाय files पर input और output operations perform करते हैं। Both functions are declared in the <stdio.h> header file. दोनों functions <stdio.h> header file में declared होते हैं। 1. fprintf() Function in C The fprintf() function is used to write formatted data into a file. It can write different types of data, such as integers, floating-point numbers and strings, using format specifiers. fprintf...

Reading and Writing Strings in a File in C Using fgets() and fputs()

Introduction to String Input and Output Functions In C language, the fgets() and fputs() functions are used to read and write strings in a file. These functions are declared in the <stdio.h> header file. Unlike fgetc() and fputc() , which handle one character at a time, these functions work with strings. C language में fgets() और fputs() functions का उपयोग किसी file में strings को read और write करने के लिए किया जाता है। ये functions <stdio.h> header file में declared होते हैं। fgetc() और fputc() एक बार में एक character पर कार्य करते हैं, जबकि ये functions strings के साथ कार्य करते हैं। 1. fputs() Function in C The fputs() function is used to write a string into a file. It writes the characters of the given string up to, but not including, the terminating null character ( '\0' ). fputs() function का उपयोग किसी file में string लिखने के लिए किया जाता है। यह दी गई string के सभी characters को write करता है, लेकिन terminating null character ( '\0' ) को ...

Reading and Writing Characters in a File in C Using fgetc() and fputc()

Introduction to Character Input and Output Functions In C language, the fgetc() and fputc() functions are used to read and write individual characters in a file. These functions are declared in the <stdio.h> header file. C language में fgetc() और fputc() functions का उपयोग किसी file में एक-एक character को read और write करने के लिए किया जाता है। ये functions <stdio.h> header file में declared होते हैं। 1. fputc() Function in C The fputc() function is used to write a single character into a file. It writes the specified character at the current file position. fputc() function का उपयोग किसी file में एक character लिखने के लिए किया जाता है। यह दिए गए character को file की current position पर लिखता है। Syntax int fputc(int character, FILE *fp); Parameters: character : The character to be written into the file. fp : A pointer to the file opened in a suitable writing mode. Return Value: The fputc() function returns the written character (as an unsigned char converted to int...

File Opening Modes in C language - r, w, a, r+, w+, a+, rb, wb, ab, rb+, wb+, ab+ with Examples

In C language, a file is opened using the fopen() function. The opening mode specifies how the program will access the file, such as reading, writing, appending or performing both reading and writing operations. The fopen() function accepts two arguments: the file name and the opening mode. It returns a FILE pointer if the file is opened successfully; otherwise, it returns NULL . C लैंग्वेज में फाइल को fopen() Function की सहायता से Open किया जाता है। Opening Mode यह निर्धारित करता है कि प्रोग्राम फाइल को किस प्रकार Access करेगा, जैसे Reading, Writing, Appending या Reading और Writing दोनों Operations करना।  fopen() Function दो Arguments ग्रहण करता है: फाइल का नाम और Opening Mode। फाइल सफलतापूर्वक Open होने पर यह FILE Pointer Return करता है, अन्यथा NULL Return करता है। Syntax of fopen() FILE *fopen(const char *filename, const char *mode); Example: FILE *fp; fp = fopen("abc.txt", "r"); Here, abc.txt is the file name and r is the opening mode. यहाँ abc.txt फाइ...

Opening and Closing a File in C Using fopen() and fclose()

In C language, file handling is used to store data permanently in secondary storage. Before performing any read or write operation, a file must be opened. After completing the required operations, the file should be closed. C language provides two important functions for opening and closing files: fopen() and fclose() . These functions are declared in the <stdio.h> header file. C लैंग्वेज में File Handling का उपयोग डेटा को सेकेंडरी स्टोरेज में स्थायी रूप से संग्रहित करने के लिए किया जाता है। किसी भी Read या Write Operation को करने से पहले फाइल को Open करना आवश्यक है। सभी आवश्यक Operations पूरे होने के बाद फाइल को Close कर देना चाहिए। C लैंग्वेज में फाइल को Open और Close करने के लिए दो महत्वपूर्ण Functions उपलब्ध हैं: fopen() और fclose() । ये Functions <stdio.h> Header File में उपलब्ध हैं। fopen() Function: The fopen() function is used to open an existing file or create a new file according to the specified opening mode. It accepts two arguments: the file name and the o...

File Handling in C Language – Types of Files, FILE Pointer and File Operations (फाइल हैंडलिंग)

A file is used to store logically related data and information permanently in secondary storage devices such as hard disks, SSDs and USB drives. If a programmer wants to store records and program output permanently, file handling is used. In C language, file handling allows a programmer to create, open, read, write, append, close, rename and delete files. फाइल का उपयोग तार्किक रूप से संबंधित डेटा एवं जानकारी को हार्ड डिस्क, SSD और USB ड्राइव जैसे सेकेंडरी स्टोरेज डिवाइस में स्थायी रूप से संग्रहित करने के लिए किया जाता है। यदि प्रोग्रामर किसी रिकॉर्ड या प्रोग्राम के आउटपुट को स्थायी रूप से सुरक्षित रखना चाहता है, तो File Handling का उपयोग किया जाता है। C लैंग्वेज में File Handling की सहायता से प्रोग्रामर फाइल को Create, Open, Read, Write, Append और Close कर सकता है। इसके अलावा फाइल का नाम बदलना और उसे Delete करना भी संभव है। File Handling (फाइल हैंडलिंग)  The process of creating, accessing, reading, writing and manipulating data stored in files is called file handling . फाइल में संग...