Simple Noob problem, help

Hello everyone,

I need some one to help with my noobiness. I'm new to C++ and i don't understand well.
I have this 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
30
31
32
33
34
35
36
37
38
39
40
int main(void) {

	int dr_type=99;
	char dr_avail[MAX_PATH];
	char *temp=dr_avail;
	
	GetLogicalDriveStrings(MAX_PATH,dr_avail);
	while(*temp!=NULL) { // Split the buffer by null
		dr_type=GetDriveType(temp);
		switch(dr_type) {
			case 2: // Removable Drive
			printf_s("%s : Removable Drive\n",temp);

			char Drive[sizeof(temp)+1];
			sprintf_s(Drive, "%s", temp);
            char Label[MAX_PATH];
            DWORD dwDontNeedThis;
            GetVolumeInformation ( Drive, Label, sizeof ( Label ), NULL, &dwDontNeedThis, &dwDontNeedThis, NULL, 0 );

            printf_s("%s : Label\n",Label);
            char cLabel[2] = "N"; // ERROR HERE ??

            if(Label == cLabel){ // ERROR HERE ??
	                char *Dest; // ERROR HERE ??
			strcat(Dest,temp); // ERROR HERE ??
			strcat(Dest,"\out.txt"); // ERROR HERE ??

			if(!copyFile ("C:\\test.txt", Dest)) { // ERROR HERE ??
				printf_s("File not copied\n");
			} else {
				printf_s("File copied\n");
			}
			
} else { printf_s("Drive label NOT %s\n",cLabel); }
			break;
		}
		temp += lstrlen(temp) +1;
	}
	return 0;
}


Check // ERROR HERE ??
How i can pass correct path to copyFile function: bool copyFile (const char SRC[], const char DEST[]);

Also Label of drive is N but if(Label == cLabel) NOT working.
Can you help with my noob problems? Thanks in advance
Also Label of drive is N but if(Label == cLabel) NOT working.

For equality-checking of c-style strings you have to use strcmp(): http://www.cplusplus.com/reference/cstring/strcmp/
Fransje, Thank you

I read it, now first problem still there, how to solve that ?

EDIT:
Program crash and compiler gives:
warning C4700: uninitialized local variable 'Dest' used
Last edited on
Ok, I solved it!

Thank for tour reply, was appreciated.
This
1
2
3
char *Dest; // ERROR HERE ??
			strcat(Dest,temp); // ERROR HERE ??
			strcat(Dest,"\out.txt"); // ERROR HERE ?? 

should be:
1
2
3
char Dest[MAX_PATH];
			strcpy(Dest,temp);
			strcat(Dest,"\out.txt");
Topic archived. No new replies allowed.