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.

DLL Talk / strings in structures using c++??

Author
Message
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 26th Sep 2004 19:02
Im refreshing my C++ and yay im rusty!

Im currently exploring structures.

is it possible to create a string in a structure using C++?
this wont compile due to that problem, any ideas.?



If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
Torrey
20
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 26th Sep 2004 19:32
I don't really code in C++, but shouldn't it be:



You can change the size limit of FirstName to whatever.
IanG
20
Years of Service
User Offline
Joined: 25th Sep 2004
Location: Cyberspace
Posted: 26th Sep 2004 19:36
in your code snippet you haave forgotten to include the string header



try that

Used to be Phoenix Insane : PC Spec-AMD Athlon 2.0Ghz,GeForce FX5200 128mb,512MB of ram, Win XP Pro SP2 . Last reformat: 17/09/2004
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 26th Sep 2004 20:32
dam thankyou Ian!, so simple.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
IanG
20
Years of Service
User Offline
Joined: 25th Sep 2004
Location: Cyberspace
Posted: 26th Sep 2004 21:15
headers can be a right pain sometimes - the compiler never tells you if your missing one

Used to be Phoenix Insane : PC Spec-AMD Athlon 2.0Ghz,GeForce FX5200 128mb,512MB of ram, Win XP Pro SP2 . Last reformat: 17/09/2004
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 27th Sep 2004 00:00
Well how's the compiler supposed to know if you meant to include one? lol. The only way it would do that is by searching every single header file on the HDD and checking to see if the invalid class/struct/function/etc is in it, which would take the compiler ages to do.


"Computers are useless they can only give you answers."
IanG
20
Years of Service
User Offline
Joined: 25th Sep 2004
Location: Cyberspace
Posted: 27th Sep 2004 01:28
too true

Used to be Phoenix Insane : PC Spec-AMD Athlon 2.0Ghz,GeForce FX5200 128mb,512MB of ram, Win XP Pro SP2 . Last reformat: 17/09/2004
Torrey
20
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 27th Sep 2004 02:23
C++ is on my list of things to tackle sometime soon. I know tons of programming languages, even low level coding, but for some reason I neglected C/C++.

Would it have worked if you used my suggestion? I'm still curious even though other people gave the right answer.
IanG
20
Years of Service
User Offline
Joined: 25th Sep 2004
Location: Cyberspace
Posted: 27th Sep 2004 02:36
yeah it would of worked, it just would of limited it to 32 characters

Used to be Phoenix Insane : PC Spec-AMD Athlon 2.0Ghz,GeForce FX5200 128mb,512MB of ram, Win XP Pro SP2 . Last reformat: 17/09/2004
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 27th Sep 2004 16:38
I explored your method torrey and it didnt seem to work, perhaps its just my syntax or devc++ being painfull.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 27th Sep 2004 16:49
Also: I forgot to ask.

theres an include called <cstring>, can anyone elaborate the differences between this one and the standard include <string>

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 27th Sep 2004 19:02
<string> holds various string functions for C - <CString> holds various string functions for C++


Come to the UK Convention on the 23rd & 24th of October
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 27th Sep 2004 21:40
thanks mate.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 27th Sep 2004 22:11
Thats okay


Come to the UK Convention on the 23rd & 24th of October
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Sep 2004 06:11
Whoops, wrong way round TCA.

string - C++ String object
cstring - C string functions in the std namespace
string.h - C string functions in the global namespace

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 28th Sep 2004 14:27
thanks again.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself
Mussi
21
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 29th Sep 2004 06:08 Edited at: 29th Sep 2004 06:08
you could also allocate dynamic memory for chars, never knew there was a string type lol



Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb

Login to post a reply

Server time is: 2024-11-21 11:12:18
Your offset time is: 2024-11-21 11:12:18