I have to write a very small app in VC++ for my small shop. They want it written in VC++, otherwise I'd do this in Java or C#. Anyway, at one point, they want to record which NT USER performed a transaction. They specifically said: "We want whatever Windows XP recognizes the current user as. So, whoever is logged into Windows, user their ID." How do I do this? In really easy in Java and C#, but I don't know offhand how to do it in VC++. Info: Windows XP Pro (Some MIGHT have Win2000, but 99% have XP) I did this once in VB (might have hit a .dll to get the info) and it still works under XP. But the code is gone, so I don't know which DLL. Thanks, Chris
canniballl
Posts
-
NT User ID Using Visual C++ -
reading in a file and storing the words in a char[]Here's your problem: strcpy() copies the contents from one character-array to another. in the string class, c_str points to the char-array (which is good). However, you're telling strcpy() to copy the contents of c_str to a single character in the array (Name[i] signifies the i-th character in Name). Looking at your strcuture, it "LOOKS" like Name and Unit are supposed to be character-arrays (strings) of length 47, and there are 10 elements of type TSimHeader, which equates to 10 character-arrays (string) of length 47. If this is the case, you must change the loop for 10 entries instead of 47. string name, unit,min,max,value ; for(int i = 0 ; i < 10 ; i++){ getline(fin, name, ',') ; if(name == "STOP") break ; getline(fin, unit, ',') ; getline(fin, min, ',') ; getline(fin, max, ',') ; getline(fin, value) ; // The following assumes that name and unit // are less than 47 characters long strcpy(TSimHeader_arr[i].Name, name.c_str()) ; strcpy(TSimHeader_arr[i].Unit, unit.c_str()) ; TSimHeader_arr[i].Min[i] = atof(min.c_str()) ; TSimHeader_arr[i].Max[i] = atof(max.c_str()) ; TSimSignal_arr[i].Value[i] = atof(value.c_str()) ; sig_count ++ ; } Again, this is assuming I interpretted this correctly.