Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Adding strings to char*

Author
Message
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 21st Aug 2006 20:16
I think I posted this before, but I could not find it.

How can I add a string a char* variable?

szAlias + ".txt";
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 21st Aug 2006 21:47 Edited at: 23rd Aug 2006 18:57
like that (c code)



Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 21st Aug 2006 23:53 Edited at: 22nd Aug 2006 00:13
Okay thanks for that, now I am having a problem. How can I compare my results that I get?

I have a message box just under this code that prints the values for szPassword and szTempString and they both have the same values, but it treats it as if they were not equal.




EDIT:

I also have this problem now with writing to a file.

It doesnt write to the file!!!!

Miguel Melo
19
Years of Service
User Offline
Joined: 8th Aug 2005
Location:
Posted: 22nd Aug 2006 00:37
You can't compare the contents of C strings with == - that will compare if both strings point _to the same memory spot_ (i.e. are physically the same string). Use strcmp() to compare contents of strings.

I have vague plans for World Domination
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 22nd Aug 2006 00:55
Thanks that worked!

Now I am left with the with the other problem of not writing to the file




OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 22nd Aug 2006 11:58
OpenToWrite will only work if the file doesn't already exist.

Come to the last Unofficial DBPro Convention (http://convention.logicstudios.net/)
Supplying "NO" since 1974...
The Scorpion
22
Years of Service
User Offline
Joined: 12th Oct 2002
Location: United States
Posted: 23rd Aug 2006 14:35 Edited at: 23rd Aug 2006 14:40
For concatenating strings you can also use the strcat() for strncat() functions. I would recommend them when not writing to a file.

strcat(*char destination, *char source)
strncat( *char destination, *char source, char_quota) [the char_quota sets a limit on how many characters will be added as to restrict hacking into addresses of the instruction pointer].

To reset a character array string to empty (as to not infinately add to it) just use strcpy(*char destination, *char source).

Example:


Much regards,
The Scorpion
--Site Temporarily Out of Service--

Login to post a reply

Server time is: 2024-11-19 07:16:38
Your offset time is: 2024-11-19 07:16:38