Jump to content

Help needed: beginner question

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Corum

Corum

    Newbie

  • Members
  • Pip
  • 3 posts
Hello. I have recently started an algorithm chair, and having no experience using C++ (only Matlab), I've got a question!

Create 2 .txt files, with 10 numbers each, and make a program that reads those values and creates a vector for each file. Adds the corresponding values together and make a third vector with the answer, writing a new .txt file displaying this third vector.

I did this exercise in class, but have since lost the code. Any help on this? Is it just attributing a vector to fopen?

Edited by Corum, 28 February 2011 - 01:46 PM.


#2
Corum

Corum

    Newbie

  • Members
  • Pip
  • 3 posts
If someone can just point me in the direction of how to create a vector from a .txt file...

#3
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
To read files use ifstream from <fstream> and you can use STL's vector container as well (located in <vector>).

Edited by Flying Dutchman, 02 March 2011 - 10:57 AM.
added links

A conclusion is where you got tired of thinking.
#define class struct    // All is public.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users