C Program to read the content of file using fgets
[crayon-6286376c300c6508475423/] Output : [crayon-6286376c300cf367648381/] Explanation :
[crayon-6286376c300c6508475423/] Output : [crayon-6286376c300cf367648381/] Explanation :
We are reading one file character by character and same character is written in the other file which is opened in writing mode.
Re Position the file pointer using fseek() and print the last n characters from the file.
Read the single file character by character and change the case of character to uppercase and write the character to the file opened in write mode.
Compare two files in a C Programming Program : C Program to Compare two text/data files in C Programming Check whether two files are identical or not. [crayon-6286376c31bb0802931114/] Explanation : Firstly Declare two file pointers for two files. Open two files in read mode. Now Inside while loop read both files character by character. Check both characters whether they are equal or not. If inside if statement ch1 = EOF and ch2=EOF then both files are said to be equal otherwise both files are non identicle.
Program : Copy Text From One File to Other File [crayon-6286376c31f39994353755/] Explanation : To copy a text from one file to another we have to follow following Steps : Step 1 : Open Source File in Read Mode [crayon-6286376c31f40012938626/] Step 2 : Open Target File in Write Mode [crayon-6286376c31f43009666185/] Step 3 : Read Source File Character by Character [crayon-6286376c31f46144156794/] "fgetc" will read character from source file. Check whether character is "End Character of File" or not , if yes then Terminate Loop "putc" will write Single Character on File Pointed [...]
Program : Write on the Data File [crayon-6286376c3256d547880330/] Output : [crayon-6286376c32574762374726/]
Program : [crayon-6286376c32b4f338729645/] Output : [crayon-6286376c32b56976546754/] Explanation : [crayon-6286376c32b59339950271/] __FILE__ is Standard Predefined Macros in C Programming. This macro will expand to the name of current file path. Suppose we have saved this source code at path - [crayon-6286376c32b5c132629256/] then [crayon-6286376c32b5e702480424/] will be expanded as - [crayon-6286376c32b61963242622/]