text-files

Reading a data from a file and writing it to a linked list

六眼飞鱼酱① 提交于 2019-12-26 08:56:41
问题 #include<stdio.h> struct Node{ char *name; int time; int sec; int x; int y; struct Node *next; }; int main(){ FILE *file; int index; struct Node *data=malloc(sizeof(struct Node)); struct Node *tmp=data,*tmp2=data; int enter; file=fopen("data.txt","r"); if(file==NULL){ printf("File was not opened!\n"); return 0; } while(!feof(file)){ tmp=malloc(sizeof(struct Node)); fscanf(file,"%d",&index); fscanf(file,"%d",&tmp->time); fscanf(file,"%d",&tmp->sec); fscanf(file,"%d",&tmp->x); fscanf(file,"%d",

Reading a data from a file and writing it to a linked list

本秂侑毒 提交于 2019-12-26 08:53:26
问题 #include<stdio.h> struct Node{ char *name; int time; int sec; int x; int y; struct Node *next; }; int main(){ FILE *file; int index; struct Node *data=malloc(sizeof(struct Node)); struct Node *tmp=data,*tmp2=data; int enter; file=fopen("data.txt","r"); if(file==NULL){ printf("File was not opened!\n"); return 0; } while(!feof(file)){ tmp=malloc(sizeof(struct Node)); fscanf(file,"%d",&index); fscanf(file,"%d",&tmp->time); fscanf(file,"%d",&tmp->sec); fscanf(file,"%d",&tmp->x); fscanf(file,"%d",

Writing List<String> contents to text file after deleting string

妖精的绣舞 提交于 2019-12-26 07:19:35
问题 I'm trying to get the contents of a Text File, delete a line of string, and re-write back to the Text File, deleting the line of string. I'm using StreamReader to get the text, importing into a List, removing the string, then rewriting using StreamWriter. My problems arises somewhere around the removing or writing of the string. Instead of writing back the existing, non deleted contents to the text file, all the text is replaced with : System.Collections.Generic.List`1[System.String] My code

Writing List<String> contents to text file after deleting string

时光毁灭记忆、已成空白 提交于 2019-12-26 07:19:11
问题 I'm trying to get the contents of a Text File, delete a line of string, and re-write back to the Text File, deleting the line of string. I'm using StreamReader to get the text, importing into a List, removing the string, then rewriting using StreamWriter. My problems arises somewhere around the removing or writing of the string. Instead of writing back the existing, non deleted contents to the text file, all the text is replaced with : System.Collections.Generic.List`1[System.String] My code

sorting files in directory by size using java array list [duplicate]

感情迁移 提交于 2019-12-25 18:59:55
问题 This question already has answers here : How can I sort files in a directory in java? (2 answers) Closed 5 years ago . The directory has n number of files.I am creating class, it will sort files by size from directory using java arraylist. I can read the file name and size. but how to sort the files by size? import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; public class

How to read numbers on text files using turbo c++ 4.0?

无人久伴 提交于 2019-12-25 18:36:42
问题 I am a beginner in programming and I am trying to make a code that reads 2 numbers from a file and then displays it in the output window on turbo c++. My code only reads the first number and produces incorrect output for the second number. #include<iostream.h> #include<fstream.h> #include<conio.h> void main() { int x, y; clrscr(); ifstream inFile; ofstream outFile; inFile.open("prac.txt"); while(!inFile.eof()) inFile >> x >> y; cout << x << " " << y; inFile.close(); } 回答1: #include<iostream.h

Making a 2d array from a text file

為{幸葍}努か 提交于 2019-12-25 18:32:47
问题 Im working with a sparse matrix and im given a text file like this: 0 3 1.2 2 5 3.2 3 0 2.1 3 5 4.2 4 5 2.2 0 0 5.2 Basically the way it works is the number 1.2 goes on the position [0] [3] and the elements of the matriz that are not mentioned stay at 0, so in this case it should look like this: 5.2 0 0 1.2 0 0 0 0 0 0 0 0 0 0 0 0 0 3.2 2.1 0 0 0 0 4.2 0 0 0 0 0 2.2 回答1: OP wrote this in the comments: Im so sorry but my teacher clarified everything just now... it turns out that, for each line

Repeatedly update contents of a list box while maintaining user control

荒凉一梦 提交于 2019-12-25 17:48:05
问题 In VBA, I am repeatedly updating the contents of a list box with the text of a steadily growing text file. Is there any way to let the user maintain control (scroll the list box, press a button) while the loop that I'm in to update the list box is running? An alternative to application.wait would also work; as in, update -> wait x seconds (where the user can still do stuff -> update again -> repeat. 回答1: Here's a start. In a regular module, paste this code: Sub ShowUserForm() UserForm1.Show

Dynamic Checkbox from a txt file entry on a WinForm UI

╄→尐↘猪︶ㄣ 提交于 2019-12-25 16:47:01
问题 Good Morning; Actually have 2 questions. My first is what is this called? A Program? A Module? WhatIsThisCalled() { //workToBeDone } I'm trying to create dynamic checkbox(s) from each entry in a text file. I'm trying to reuse the code so I have tried to create the module in a logic file. I feel like I've done this correctly, but I can't test it. I can not figure out how to reference this.Controls.Add(chk[I]); to the winForm I want to call it on. The error I get is about it being illegal in a

PHP Write To Text File

青春壹個敷衍的年華 提交于 2019-12-25 14:01:17
问题 When I write to text file , all data printed on first line , although I used PHP_EOL , I want to print it line by line. $file_Name = './textFilesData/Accounts_Deafult_Data.txt'; $current = file_get_contents($file_Name); $c = 0; while ( $c < 5 ) { $current = 'Rafat'; $current = $current.PHP_EOL; $c++; } file_put_contents($file_Name, $current); 回答1: Adding \r\n should work $file_Name = './textFilesData/Accounts_Deafult_Data.txt'; $current = file_get_contents($file_Name); $c = 0; while ( $c < 5