Write a line of code that will declare a file variable named data.
Assuming that the variable data was correctly created in the previous problem, write a line of code that will associate the variable with a file named grades.txt that is being opened for reading.
Assuming that grades.txt only contains integers, write a line of code that will use the variable data to read in the first integer and store in a variable named test1 that has already been declared.
ANSWER IN C PLEASE
Hi,
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main(){
FILE *file;
//get the file pointer
char filename[190],c;
printf("Enter the filename to open\n");
//Enter the name of the file with complete
path
scanf("%s",filename);
file = fopen(filename,"r");
//opening file
if(file == NULL)
{
printf("Can not open
file\n"); //if
not found or wrong input
exit(0);
}
c = fgetc(file);
//reding file data
while(c!=EOF)
{
printf("%c",c);
//printing
data character by character
c = fgetc(file);
//getting next
character
}
fclose(file);
//closing
file
}
THANKS
Write a line of code that will declare a file variable named data. Assuming that the...
(Create a binary data file) Write a program to create a file named CreateBinaryFile.dat if it does not exist. Append new data to it if it already exists. Write 50 integers created randomly into the file using binary I/O.
Write you code in a class named HighScores, in file named HighScores.java. Write a program that records high-score data for a fictitious game. The program will ask the user to enter five names, and five scores. It will store the data in memory, and print it back out sorted by score. The output from your program should look approximately like this: Enter the name for score #1: Suzy Enter the score for score #1: 600 Enter the name for score...
implicit none ! Declare File Read Variables CHARACTER(255) :: Line INTEGER :: CP ! Character position in Line INTEGER :: File_Read_Status ! Declare character constants CHARACTER :: Tab > ACHAR(1) CHARACTER :: Space = " " ! Read all lines in the file DO READ(*,'(A)',iostat = File_Read_Status) Line ! Exit if end of file IF (File_Read_Status < 0) EXIT ! Skip leading white space DO CP = 1, LEN_TRIM(Line) IF...
A file named "numbers.txt" contains an unknown number of lines, each consisting of a single positive integer. Write some code that reads through the file and stores the largest number read in a variable named "maxvalue". Use Python
Write a complete Java program in a file caled Module1Progrom.java that reads all the tokens from a file named dota.txt that is to be found in the same directory as the running program. The program should ignore al tokens that cannot be read as an integer and read only the ones that can. After reading all of the integers, the program should print all the integers back to the screen, one per line, from the smalest to the largest. For...
Step 1: Getting Started Create a new .java file named Lab12.java. At the beginning of this file, include your assignment documentation code block. After the documentation block, you will need several import statements. import java.util.Scanner; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; Next, declare the Lab12 class and define the main function. public class Lab12 { public static void main (String [] args) { Step 2: Declaring Variables For this section of the lab, you will need to declare...
Question 2 (a) Provide a single line of C++ code that will declare a variable that points to a string value, the variable is named x. [2 marks] (b) You have array c declared as string *c [5]; Give the single line of C+ + code that will assign the string pointer stored in variable x (from above) to the third element of the array c. [2 marks] (c) Write a for loop that initialises the contents of each element...
in c++ please HW09: Read/Write File Ints Now that we've had a taste of what file I/O is all about, here's your chance to try it out on your own! You're to write a program that will prompt the user if he/she would like to read ints from a file (and have them displayed to stdout) or write ints to a file for safekeeping. If the user wishes to save a set of numbers, then the file nums.txt is opened...
Tasks Write a program that prints in text mode Project 2 written by YOURNAME And shows in a graphical way, as shown below, the names stored in a file. The coordinates to print the names will be also read from another file. Here is an example of what your graphic output should look like with the two files that are provided for test purposes. Drawing Panel Adam Bernie Cameron Daniel Fanny Gerard Harold Issac Jackie Raitlyn Note that the colors...
Write a program to create a file named integerFile.txt if it does not exist. Write 100 integers created randomly into the file using text I/O. The random integers should be in the range 0 to 100 (including 0 and 100). Integers should be separated by spaces in the file. Read the data back from the file and display the data in increasing order This is what I have so far: import java.io.File; import java.util.Scanner; import java.io.PrintWriter; public class integerFile {...