Computer Science, asked by tulsibalramsingh8, 1 month ago

D. Write a program for creating a text file named "student.txt" and write two lines in it. What will be position of file pointer if you read one line?​

Answers

Answered by kajalpal1975
1

Answer:

Python:-

with open("student.txt", "w") as f:

f.writelines(["This is a file", "Hello World"])

Java:-

import java.io.*;

public class FileDemo {

public static void main(String[] args) throws Exception {

PrintWriter p = new PrintWriter("student.txt");

p.println("This is a file");

p.println("Hello World");

p.close();

}

}

C:-

#include<stdio.h>

int main() {

FILE *fp = fopen("student.txt", "w");

fprintf(fp, "%s\n", "This is a file");

fprintf(fp, "%s\n", "Hello World");

fclose(fp);

return 0;

}

After reading one line the position of the file pointer will be at the start of the second line, before Hello World

Please mark me as the brainliest.

Similar questions