text-files

How to read data from files in Turbo c++ 4.0?

随声附和 提交于 2019-12-02 13:26:59
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(); } The file contains the numbers: 2 3 Output : 2 0 Output when called as a function: 2 -28903 which is very different if I call it

how to write into a text file in Java

放肆的年华 提交于 2019-12-02 12:54:26
问题 I am doing a project in java and in that i need to add and modify my text file at runtime,which is grouped in the jar. I am using class.getResourceAsStream(filename) this method we can read that file from class path. i want to write into the same textfile. What is the possible solution for this. If i can't update the text file in jar what other solution is there? Appreciate any help. 回答1: The easiest solution here is to not put the file in the jar. It sounds like you are putting files in your

Input mismatch when reading double from file

ε祈祈猫儿з 提交于 2019-12-02 11:48:47
问题 I have to write a program that will read the names and balances from text file "balances.txt" and organize into a report that will then sum up the balances into a total. This is what the file contains: JAKIE JOHNSON,2051.59 SAMUEL PAUL SMITH,10842.23 ELISE ELLISON,720.54 I had originally written the code which gave me exactly what I wanted, but was told not use loops, arrays, or parseDouble . I've now tried the following, but I keep getting an error every time I used nextDouble . The code:

vbscript code to read input from text file avoiding manual efforts

微笑、不失礼 提交于 2019-12-02 11:33:57
I am drilling down Internet to get Vbscript code, where input is read from text file one per line and pass it to the commands in script. I am just a beginner and need help with this. Basically I am gathering script to get pending patches of servers in our environment. The script looks like below: '# '# ServerPendingUpdates.vbs '# '# Usage: cscript ServerPendingUpdates.vbs {servername} {servername} {servername} {servername} '# If no {servername} specified then 'localhost' assumed '# '# To do: Error handling '# Option Explicit Dim strServer : strServer = GetArgValue(0,"localhost") '# '# Loop

PHP run code from txt file

十年热恋 提交于 2019-12-02 10:31:56
问题 If i had a text file on my web server, which contains full PHP code, all properly formatted, could i use PHP fopen to read the text file and echo the output of the PHP to the browser. Ie. Run PHP code that is held in a text file rather than hard coded? Thanks 回答1: It's perfectly possible to do this (it's just another file after all), although I'd be tempted to directly include it rather that messing around with fopen/eval, etc. (N.B.: The file would of course have to be "fully formed" and

How to reading .txt file and rewriting by adding space after specific position / index for each line in python

跟風遠走 提交于 2019-12-02 09:47:12
I want to read .txt file and add space after a specific position/index for each line. please consider below example for more details. suppose my file contains 12345 678 91011 12 1314 In the above file, the first row contains space after a specific position/index [4] , then after position/index[8], after position/index[14] and after position/index[17] Expected output : I want every row in the file is having space after a specific position. i.e for the first row, I want to add space after index [2], then add space after index [6], then add space after index[11], then add space after index [21],

How to search and replace text from one file to another using Python?

孤街浪徒 提交于 2019-12-02 08:56:12
问题 I have a file file1.txt : I Show more flower you can see by link All is Beautyfull.You Can View Here ! Link View : http://lincoln.com/view/12432134/flower1.jpg http://lincoln.com/view/34645645/flower3456.jpg http://lincoln.com/view/75634534/flower56.jpg http://lincoln.com/view/86764454/flower2.jpg and another one file2.txt : http://lincoln.com/view/43645645/flower1.jpg http://lincoln.com/view/84344454/flower3456.jpg http://lincoln.com/view/43343433/flower56.jpg http://lincoln.com/view

Read each line in file and put each line into a string

…衆ロ難τιáo~ 提交于 2019-12-02 08:40:40
I have a text file that I want to read in and put each line from the file into its own string. So the file will have 4 lines: 2017-01-20 05:59:30 +353879833382 971575 Michael So in the code I need to read in the file and split up each line and put them into a string i.e the first line will equal to string date, second line will equal to string time etc Code: public static void ParseTXTFile(string FileName, int CompanyID) { try { FileInfo file = new FileInfo(FileName); string Date; string Time; string Phone; string JobNo; string Name; using (CsvReader reader = new CsvReader(new StreamReader

using log4j for clearing a file?

◇◆丶佛笑我妖孽 提交于 2019-12-02 08:10:56
问题 im using log4j to write into a file with the following properties file : log4j.rootLogger=DEBUG, FA #File Appender log4j.appender.FA=org.apache.log4j.FileAppender log4j.appender.FA.File=temp.ppr log4j.appender.FA.layout=org.apache.log4j.PatternLayout log4j.appender.FA.layout.ConversionPattern= %m%n My problem is , that in each run of my program , i want to clear the file "temp.ppr" , and then write to it efficiently with lo4j? or do you recommend other solutions? thanks 回答1: You could do this

Xcode 7.1 beta: Content Of File Error

好久不见. 提交于 2019-12-02 07:51:31
I had just finished the final touches to my swift app. But after upgrading to Beta 7 its giving me errors for the 'ContentOfFile' String. can anyone help me understand how I can go about fixing this please? here's what i've got ATM. //Reads the Text File if var path = NSBundle.mainBundle().pathForResource("Chapters", ofType: "txt"){ //Reads the Text File into one Huge String var data = String(contentsOfFile:path, encoding: NSUTF8StringEncoding, error: nil) //sets String content of the Text File as an Array. With each string start at \n (new line) if var content = (data){ //from the mass string