LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SriptFile Logic help

Darnell:

 

Based on your prototype, Write_HrChecks_To_Script_File() is looking for a pointer to a string, not a long or HRESULT.

 

int Write_HrChecks_To_Script_File (char stringToWrite[]);

 

When you cast hresult as (char*), you are casting it as a pointer to char.  You are not converting it to a string.

 

You created a pointer to char with (char*) hresult, but you haven't initialized the char or string that it points to.

Since (char*) hresult is just a pointer, that is your uninitialized string that generates the error.

 

Since you didn't post the declaration for g_comError, it looks like you're doing the same thing with it: creating a pointer that doesn't point to anything since you haven't initialized it. 

 

HRCHECK_FILE((char*)g_comError.sCode);

 

What you are doing is similar to doing the following.

 

char *myString;              // myString is a pointer to char   

printf("%s", myString);   // error: you can't use myString yet because you haven't initialized it.

 

What do you want the string you pass to Write_HrChecks_To_Script_File() to contain?  If you want it to contain the number, you could do something like the following in the calling routine.

 

char sMsg[256];

 

.....

 

sprintf(sMsg, "%d", g_comError.sCode);

HRCHECK_FILE(sMsg);

Message 31 of 33
(1,006 Views)

yea I saw that at the last minute, I had to hit myself in the head for that one. Al S i have a question, pertaining to pointers.  when , and why do people double*** or

double ** 

 

also do you have good site on pointers , i need to refreshing my memory a little bit. 

0 Kudos
Message 32 of 33
(1,000 Views)
thanks I fix the problem, I wasnt paying attention, what i had to do is do a up stack and took me to every function when i was making that mistake
0 Kudos
Message 33 of 33
(997 Views)