File_Sum_of_Integers

Ratings: 1 Star2 Stars3 Stars4 Stars5 Stars (3.00 out of 5) - Rate Now!
Loading...

Download Category: ,

File_Sum_of_Integers.zip - (5.51 MB)
[
File_Sum_of_Integers/data.txt
File_Sum_of_Integers/Debug/
File_Sum_of_Integers/Debug/cl.command.1.tlog
File_Sum_of_Integers/Debug/CL.read.1.tlog
File_Sum_of_Integers/Debug/CL.write.1.tlog
File_Sum_of_Integers/Debug/File_Sum_of_Integers.exe
File_Sum_of_Integers/Debug/File_Sum_of_Integers.exe.embed.manifest
File_Sum_of_Integers/Debug/File_Sum_of_Integers.exe.embed.manifest.res
File_Sum_of_Integers/Debug/File_Sum_of_Integers.exe.intermediate.manifest
File_Sum_of_Integers/Debug/File_Sum_of_Integers.ilk
File_Sum_of_Integers/Debug/File_Sum_of_Integers.lastbuildstate
File_Sum_of_Integers/Debug/File_Sum_of_Integers.log
File_Sum_of_Integers/Debug/File_Sum_of_Integers.obj
File_Sum_of_Integers/Debug/File_Sum_of_Integers.pdb
File_Sum_of_Integers/Debug/File_Sum_of_Integers.vcxprojResolveAssemblyReference.cache
File_Sum_of_Integers/Debug/File_Sum_of_Integers.write.1.tlog
File_Sum_of_Integers/Debug/File_Sum_of_Integers_manifest.rc
File_Sum_of_Integers/Debug/link.command.1.tlog
File_Sum_of_Integers/Debug/link.read.1.tlog
File_Sum_of_Integers/Debug/link.write.1.tlog
File_Sum_of_Integers/Debug/link-cvtres.read.1.tlog
File_Sum_of_Integers/Debug/link-cvtres.write.1.tlog
File_Sum_of_Integers/Debug/mt.command.1.tlog
File_Sum_of_Integers/Debug/mt.read.1.tlog
File_Sum_of_Integers/Debug/mt.write.1.tlog
File_Sum_of_Integers/Debug/rc.command.1.tlog
File_Sum_of_Integers/Debug/rc.read.1.tlog
File_Sum_of_Integers/Debug/rc.write.1.tlog
File_Sum_of_Integers/Debug/vc100.idb
File_Sum_of_Integers/Debug/vc100.pdb
File_Sum_of_Integers/File_Sum_of_Integers.cpp
File_Sum_of_Integers/File_Sum_of_Integers.png
File_Sum_of_Integers/File_Sum_of_Integers.sdf
File_Sum_of_Integers/File_Sum_of_Integers.sln
File_Sum_of_Integers/File_Sum_of_Integers.suo
File_Sum_of_Integers/File_Sum_of_Integers.vcxproj
File_Sum_of_Integers/File_Sum_of_Integers.vcxproj.filters
File_Sum_of_Integers/File_Sum_of_Integers.vcxproj.user
File_Sum_of_Integers/ipch/
File_Sum_of_Integers/ipch/file_sum_of_integers-4668f868/
File_Sum_of_Integers/ipch/file_sum_of_integers-4668f868/file_sum_of_integers-b27f4834.ipch
File_Sum_of_Integers/Question.txt
]

Write a program that prints “Please enter your filename.”, reads in the name of the file, and then tries to open it. If the input file is there and can be opened, the program should read the list of integers in the file, which will have one integer per line as in the following example:

14
9
12
-6
-30
8
109
Note: This example is just to demonstrate the format of the input file. Your program would not print these values out to the console or to the output file.

The program will then add together all the integers in the file, create an output file called sum.txt, write the sum to that file (just that number – no additional text), and then print (to the console) “result written to sum.txt”. Remember to close both the input and output files. If the input file is not there (or is there but couldn’t be opened for some reason), the program should just print out “could not access file”.

Using a string variable as the parameter of the open function is a C++11 feature, so to compile, you’ll need the “-std=c++0x” flag as discussed in the section “Note on different C++ standards”.

The file must be named: fileAdder.cpp

Get a fresh solution of this question. Ask it now to our experts.
doubt

Ask Your Question

We have verified professionals who are ready to answer your question.

time

Save Time and Money

We choose experts who can quickly answer your question and that suit your budget.

download

Get Your Answer

Your satisfaction is 100% guaranteed. You can keep on asking questions until you get the answer you need.