Can't seem to print argv[]

I'm trying to be make a console program that looks in a specified folder and shows the name of the first file. In trying to print argv[1] (the directory path) it prints a couple lines of question marks and occasionally some other different symbols. The same occurs when I try to print the name of the first file. I'm a total n00b and this is probably pretty dumb, I just can't seem to get it. Here's my code:

#include <iostream>
#include <String>
#include <windows.h>
#include <tchar.h>
#include <strsafe.h>
#include <io.h>
using namespace std;

int main(int argc, TCHAR* argv[]){


wstring d = wstring(argv[1]);

int counter = 0;
bool working = true;
LARGE_INTEGER fileSize;
TCHAR directory[MAX_PATH];
size_t length_of_arg;

WIN32_FIND_DATA data;
HANDLE finder;

StringCchLength(argv[1], MAX_PATH, &length_of_arg);

cout << "Target directory is: \n";
wcout << d;

StringCchCopy(directory, MAX_PATH, argv[1]);
StringCchCat(directory, MAX_PATH, TEXT("\\*"));

finder = FindFirstFile(argv[1], &data);

_tprintf(TEXT("The first file found is %s \n"), data.cFileName);
FindClose(finder);
}

Thanks in advance to anyone with some tips :)
Last edited on
Topic archived. No new replies allowed.