unable to start program

Oct 26, 2012 at 2:53pm
what can be the reason that i get this error while trying debugging?
Oct 26, 2012 at 3:01pm
closed account (NbMiz8AR)
can u show me the error. like copy and paste the error
Last edited on Oct 26, 2012 at 3:01pm
Oct 26, 2012 at 3:01pm
An error would be nice :b
Oct 26, 2012 at 3:15pm
when i try to debug it says in a little window "unable to start program.system could'nt find the file.

my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 1sutundist.cpp : main project file.
#include "stdafx.h"
using namespace std;
void main(){
  float line;
  string str[32][75];
  int a=0,b=0,i,j,k;
  ifstream yourfile ("iristrain1sutun.txt");
  if (yourfile.is_open()){
	  while ( yourfile.good() )  {
	 getline (yourfile,str[a][b],' ');
     cout << str[a][b] <<  endl;
	  if(a==31){
		a=0;
		b++;
		getline(yourfile,str[a][b],' ');}
	  a++;}
	  yourfile.close();}
  else cout << "Unable to open file"; 
  float result[75];  
	  for(j=0;j<5;j++){
		  for(k=0;k<75;k++){
				result[k]=(str[0][0]-str[0][k])*(str[0][0]-str[0][k]);
		  }}
	  for(int i=0;i<75;i++){
		cout<< result[i]
	  }
  system("pause");
}



the error reported in commant part is:
1>------ Build started: Project: 1sutundist, Configuration: Debug Win32 ------
1> 1sutundist.cpp
1>1sutundist.cpp(23): error C2784: 'reverse_iterator<_RanIt>::difference_type std::operator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1332) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: 'reverse_iterator<_RanIt>::difference_type std::operator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1332) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: 'reverse_iterator<_RanIt>::difference_type std::operator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1332) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: '_Base1::difference_type std::operator -(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1146) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: '_Base1::difference_type std::operator -(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1146) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: '_Base1::difference_type std::operator -(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1146) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2676: binary '-' : 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
1>1sutundist.cpp(23): error C2784: 'reverse_iterator<_RanIt>::difference_type std::operator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1332) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: 'reverse_iterator<_RanIt>::difference_type std::operator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1332) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: 'reverse_iterator<_RanIt>::difference_type std::operator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1332) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: '_Base1::difference_type std::operator -(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1146) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: '_Base1::difference_type std::operator -(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1146) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2784: '_Base1::difference_type std::operator -(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::string'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1146) : see declaration of 'std::operator -'
1>1sutundist.cpp(23): error C2676: binary '-' : 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
1>1sutundist.cpp(27): error C2143: syntax error : missing ';' before '}'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Oct 26, 2012 at 3:52pm
> Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
The compilation failed, ¿how do you expect to run the program?

Missing headers, main() must return int, and trying to subtract strings.
Also, your indentation is awful
Oct 26, 2012 at 3:57pm
For a start you need to add the iostream header like below.

#include <iostream>

and as ne555 said main() should have the return type int
Oct 26, 2012 at 5:18pm
main is returnin 0 which is an integer and iostream is included in stdafx.h.
Oct 26, 2012 at 5:42pm
Main needs to be defined like

1
2
3
int main()
{
}


you may need to include fstream as well for the file operations

#include <fstream>

Also looks like you're trying to substract strings which isn't possible as far as im aware.

Topic archived. No new replies allowed.