Need help with program... I can't get past this one error!

Error- The system cannot find the file specified.

Page 1 of 1

3 Replies - 723 Views - Last Post: 17 November 2009 - 05:38 AM Rate Topic: -----

#1 H4CKC0D3R  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 16-September 09

Need help with program... I can't get past this one error!

Posted 16 November 2009 - 06:27 PM

Hi, I just coded this program today but there is one error that I can't fix.
The error is:
The system cannot find the file specified.

// Calculator.cpp : Started 11-16-09

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int main()
{
int a, b;
cout << "Hi and welcome to calculator! " << "Enter the first number...";
getline (cin, a);
cout << "Enter the second number...";
getline (cin, b);
cout << "The answer is:" << a + b;

return 0;
cin.get();
}


So please help me because its driving me crazy that I can't figure it out myself.

This post has been edited by H4CKC0D3R: 16 November 2009 - 06:39 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Need help with program... I can't get past this one error!

#2 zhanfeng  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 75
  • Joined: 09-November 08

Re: Need help with program... I can't get past this one error!

Posted 16 November 2009 - 07:48 PM

Firstly, why are you using getline to get integers? Use cin instead. Secondly, switch the order between cin.get() and return 0;

This post has been edited by zhanfeng: 16 November 2009 - 07:51 PM

Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,659
  • Joined: 23-August 08

Re: Need help with program... I can't get past this one error!

Posted 17 November 2009 - 05:28 AM

What file is it complaining about and what compiler are you using?
Was This Post Helpful? 0
  • +
  • -

#4 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 1,002
  • Joined: 30-July 08

Re: Need help with program... I can't get past this one error!

Posted 17 November 2009 - 05:38 AM

#include "stdafx.h"
must be in the same folder as the rest of the source. This might be different with different compilers. But my guess is that you do not have stdafx.h in the same folder. Put it there and the compiler will find it :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1