file-io

Understanding of file handling in C

ⅰ亾dé卋堺 提交于 2019-12-25 02:13:16
问题 How exactly do I take an input from a file in C? As in, for instance: Say i assigned a file pointer to a particular file and want to peform certain operations. What exactly is the syntax for assigning the file pointer Assume the file, is located at C:\Acads\bin\File.txt. In my code when I try this FILE *fp1; fp1=("C:\Acads\bin\File.txt","r+"); It ends up giving me an error. UPDATE: Okay so here is my main doubt. How exactly do i tell the compiler that my file is located at so and so path. I

Reading from a File to an Array - C

最后都变了- 提交于 2019-12-25 02:06:07
问题 int main() { FILE* infile1; int stockCode[15]; char stockName[100]; int stockQuantity[15]; int stockReorder[15]; int unitPrice[15]; int i; infile1 = fopen("NUSTOCK.TXT", "r"); while(fscanf(infile1, "%d %s %d %d %f", &stockCode, stockName, &stockQuantity, &stockReorder, &unitPrice) != EOF) { printf(" %3d %-18s %3d %3d %6.2f \n", stockCode, stockName, stockQuantity, stockReorder, unitPrice); } fclose(infile1); } What I'm trying to do is to take information from a file and store it into 5

Java File I/O - Text File - How to check for content?

浪尽此生 提交于 2019-12-25 01:33:41
问题 I was wondering, If i had a java class, that wanted to consult a txt file with say a list of names like tom steve jones how could i open the text file in the java program and basically see if a string contained in the program matches one of these names? so far i have come up with try { BufferedReader inputReader = new BufferedReader(new FileReader("users.txt")); while (inputReader.readLine() != null){ } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace

Java obj array to file

北城余情 提交于 2019-12-25 00:34:27
问题 Closed question please delete! 回答1: While I suggested in my comment that you use a BufferedWriter , I think it is easier to use Files.write . With that, your outputPGToFile() would look like this: private static void outputPGToFile() { try { Files.write(Paths.get("PostgradStudent.csv"), Arrays.stream(PGstudentArray).map(Object::toString).collect(Collectors.toList()), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } catch (IOException e) { e.printStackTrace(); } } (You need

C# pass file text to list when file is entered via command line argument

吃可爱长大的小学妹 提交于 2019-12-25 00:18:58
问题 I am writing a program for an assignment that is meant to read two text files and use their data to write to a third text file. I was instructed to pass the contents of the one file to a list. I have done something similar, passing the contents to an array (see below). But I can't seem to get it to work with a list. Here is what I have done in the past with arrays: StreamReader f1 = new StreamReader(args[0]); StreamReader f2 = new StreamReader(args[1]); StreamWriter p = new StreamWriter(args

Windows Phone 7 crash when accessing directory

放肆的年华 提交于 2019-12-25 00:14:11
问题 I am having trouble getting info on a directory in Windows Phone 7 with C#. My application freezes or crashes when I call: System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo("Content/Levels"); It also freezes when I try to determine the path of the application so I think this is where the problem lies. What am I possibly doing wrong and what can I do to fix this? Update: It seems this problem is related to a sequirity issue but I don't know how to resolve this. Is there possibly

file processing (for file with more than one fields) and problems associated with it

淺唱寂寞╮ 提交于 2019-12-24 22:43:03
问题 here is a code i wrote to create the symtab of a sic/xe .asm file.... #include<iostream> #include<fstream> #include<iomanip> #include"aviasm.h" using namespace std; void aviasm::crsymtab() { ofstream outs("symtab.txt",ios::out);//creating the symtab ofstream outi("intermfile.txt",ios::out);//creating the intermediate file ifstream in("asmfile.txt",ios::in);//opening the asmfile which i have already written in.seekg(0,ios::beg); char c; string str[3]; string subset; long locctr=0; int i=0;

Too many open files

本小妞迷上赌 提交于 2019-12-24 22:36:16
问题 I get an EInOutError with message 'Too many open files' when executing this code block repeatedly for some time from a number of client threads: var InputFile : Text; ... Assign (InputFile, FileName); Reset (InputFile) try // do some stuff finally CloseFile (InputFile); end; The number of client threads is approximately 10, so only 10 files can be open at any time. Is there any possibility that Delphi refuses to close files right away? Can I ensure that it does? Or am I making a mistake here?

How to read local file with Grails?

笑着哭i 提交于 2019-12-24 22:12:47
问题 When my Grails application starts, I build up a data structure from a CSV file downloaded from a remote URL. If the file is not accessible, I'd like to fall back to a local copy. Currently processing the file in the service layer, initiated using a Quartz job. What is the best practice, using Groovy, for reading a local resource in Grails? Where should I stash the file? How do I safely and properly read the file? General-case answers will be very acceptable. 回答1: I think the best way to deal

C++ Build Failed on X-Code OSX with multiple errors File IO … is unavailable: introduced in macOS 10.15

两盒软妹~` 提交于 2019-12-24 21:54:53
问题 I am getting the following error whenever I try to build my code on X-Code on my Mac. My current system: macOS: version 10.15.1 (19B88) xcode: Version 11.2.1 (11B500) my error: 'path' is unavailable: introduced in macOS 10.15 'current_path' is unavailable: introduced in macOS 10.15 'operator/' is unavailable: introduced in macOS 10.15 'path' is unavailable: introduced in macOS 10.15 'path' is unavailable: introduced in macOS 10.15 main.cpp #include <iostream> #include <iomanip> #include