I have two c++ win32 console application project. Both have exactly identical code.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
if (argc != 3){
cout << "Program needs 2 arguments";
}
else{
string filePath = argv[1];
string flag = argv[2];
unsigned long int size;
bool najden = false;
//odpri datoteko
ifstream idatoteka(filePath, ios::in | ios::binary | ios::ate);
if (idatoteka){
if (flag != "-c" && flag != "-e"){
cout << "unknown flag";
}
else{
if (flag == "-c"){
//kompresija
}
else{
//dekompresija
}
}
}
else{
cout << "This file doesn't exist\n";
}
}
system("pause");
return 0;
}
The silly thing is that one of them is giving me an error where I try to pass argv[1] and argv[2] into string variables. The error message is as follows:
cannot convert from '_TCHAR *' to 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
Since when doesn't this work and how can one of two identical projects possibly generate an error?