Information générale
Catégorie:
Fonctions Windows API
>I haven't done much work with dlls, but I see one problem. From your code it appears that rtntime will be more than one character(string). In C++ creating a char* is like creating an array. So, when you do "return(*rntime)" you will only return the first character. For example,
>
>rtntime = "hello";
>return(*rtntime); This will return "h"
>
>return(*(rtntime + 1)); This will return "e"
>
>If you are only returning one character then disregard. This sould not cause a memory error unless rtntime is null. You might want to test for null before you return the value.
>
>
>Hope this helps!
>
>James Naftel
>
>>
>> char ConvertTime(void)
>> {
>> struct tm *newtime;
>> time_t aclock;
>> char* rtntime;
>>
>> aclock=8067157205;
>>
>> newtime = localtime(&aclock);
>>
>> rtntime = asctime(newtime);
>>
>> return(*rtntime);
>>
>> }
Hi James:
What I am trying to do is return the whole string.
localtime() converts the Universal Coordinated Time (aclock) and places the result in a structure. the pointer to that structure is assigned to newtime.
asctime() converts the elements in the structure to a character string ie: "Thursday August 14, 1997 10:29 am", and assigns the pointer to this string to rtntime.
How do I then return the whole string?
Ed
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement