Results 1 to 14 of 14

Thread: Adding values to char strings...

  1. #1
    Join Date
    Apr 2005
    Location
    Pennsylvania, USA
    Posts
    520
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Adding values to char strings...

    I know this is obvious, also weather you can do it or not but i can't seem to figure it out. Anyway.... I'll show you what i've tried to do and maybe you can figure how i can do it w/o having some one have to type "ping " in. never works... problem is... if you compile the first one you'll notice it won't compile.

    Also, ignor the paths. I was too lazy to change them but i doubt it has anythign to do with this.

    it says Download Links:
    Links are hidden from guests. Please register to be able to view these links. Download Links:
    Links are hidden from guests. Please register to be able to view these links. The next one compiles but dosn't add the value to the end of the string. It just ignors it. Like i typed in "ping" in cmd.

    Download Links:
    Links are hidden from guests. Please register to be able to view these links.
    Last edited by kohlrak; 22nd-June-2005 at 08:39.

  2. #2
    Join Date
    Feb 2005
    Location
    Limbo
    Posts
    3,706
    Thanks
    0
    Thanked 2 Times in 2 Posts
    EP Points
    10

    Default

    Eh, I haven't really started getting into C++... But now I have free time, so beware! Anyway.

    This line:
    Download Links:
    Links are hidden from guests. Please register to be able to view these links. Is wrong. The "," operator executes the two functions, and returns the value of the first one.
    Now, I don't remember exactly if you could do this in C++, but you could try writing
    Download Links:
    Links are hidden from guests. Please register to be able to view these links. instead. Anyhow, I'm sure that in C there are some functions for manipulating strings, find the one that lets you append a string to the end of another, and use the appended string afterwards.

  3. #3
    Join Date
    Apr 2005
    Location
    Pennsylvania, USA
    Posts
    520
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    warning that i forgot to mention: I'm a walking syntax error.

    I did find a way.... but for some friggan reason it's not... working... I did find the code, it works everywhere but in this project... (go figure.)

    Download Links:
    Links are hidden from guests. Please register to be able to view these links. Download Links:
    Links are hidden from guests. Please register to be able to view these links. Weird... if they mean too much for during initilization... too bad.. it works every where else. Why not here... maybe i'm missing somthing in the code... i'll also try not putting it into the declaration of the variable. This thing is evil... I like C++, but i am a hands on learner and if i had a better more readable tutorial on a few of the APIs i'd get experience in fixing my damn screwups. lol But really, the problem with the help files are when they make this stuff they make a bunch of projects in 1 to explain a bunch of functions, instead of just 1 project for each thing making it clear the code is for that thing rather than saying "this is a code for this function". Why don't they tell us what the code does and a few examples of the damn function. And... it's hard getting used to the new C++ compiler. (MS Visual C++ 6.0, and finally i get a good one but the things are all messed up, hell i'm not 100% sure but i think their hello world program just had to be an exturnal file instead of putting it into the source so we would know how to edit the text from the main source instead of making it look like it's making our life easier by sorting stuff out for us when the stuff should be within the source file anyway.) Plus, it has to be in C++, i don't know C and i'm planning on making this into a DLL file or a seperate function in a bigger program. I don't know if making it a DLL would work for making it in C then the rest of the proggy in C++. I never tried for compatability errors. (nor have i ever figured out how to run an exturnal DLL file or source code. Source code is better. I know it's possible to run an exturnal source code but don't know how, that'll be my next post when i get this sorted. lol)

    Starting C++ eh? I have an easy to read C++ tutorial for starting from scratch, but i often forget things in it and get lost... That's the problem, my brain is like a computer with only 2 mb of ram. It can only do so much at one time then i have to take a break.

    Download Links:
    Links are hidden from guests. Please register to be able to view these links. oooooooo... says the system line is a syntax error... damnit...

    Try removing the "[]" from the system line and i get this... Download Links:
    Links are hidden from guests. Please register to be able to view these links. ALSO NOTE: The change of variables is because i retype the program in from memory and i have been working on other projects inbetween.
    Last edited by kohlrak; 22nd-June-2005 at 14:27.

  4. #4
    Join Date
    Feb 2005
    Location
    Limbo
    Posts
    3,706
    Thanks
    0
    Thanked 2 Times in 2 Posts
    EP Points
    10

    Default

    Isn't the char* action[] an array of char* -s of an undefined size? So, try writing action[0] instead of action[], as that would be a redefiition of the variable.

    Sorry if this does not work, as I haven't been programming for a looooooooooooong time now, unfortunately.

  5. #5
    Join Date
    Apr 2005
    Location
    Pennsylvania, USA
    Posts
    520
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'll try that, but... making it zero means it can't store information (if i'm right). Regular char is charname[1]. It has been a while since i've used C++ myself, and i've only used strings... once... (i woulda used them more if i could get the program to relize that a!=z but a==a. (I don't mean a and b are variables, i mean them as values. That would help in making a password function... but sure enough... there's a way to do that but it's extra headers and crap...)

    EDIT:

    Download Links:
    Links are hidden from guests. Please register to be able to view these links. WTF? Also when it was compiled it crashed.
    Last edited by kohlrak; 22nd-June-2005 at 14:48.

  6. #6
    Join Date
    Feb 2005
    Location
    Limbo
    Posts
    3,706
    Thanks
    0
    Thanked 2 Times in 2 Posts
    EP Points
    10

    Default

    Download Links:
    Links are hidden from guests. Please register to be able to view these links. I meant it like this. As putting the 0 in the definition would most certainly crash. The action[0] used as a pointer means the first element of the array. I still don't understand why don't you just use the built-in string manipulating functions (If there are any and if there is need for such things in C++ too)

  7. #7
    Join Date
    Apr 2005
    Location
    Pennsylvania, USA
    Posts
    520
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i didn't use 0... i used 200. i put 200 in both. oh wait.... hm... er... then waht are you saying i should do? put 20 in the declaration? then ti'd get a syntax error on compilation. And i think this is the manipulation functions (if any). Problem with weather there is or not is no one ever tells you about it.

  8. #8
    Join Date
    Feb 2005
    Location
    Limbo
    Posts
    3,706
    Thanks
    0
    Thanked 2 Times in 2 Posts
    EP Points
    10

    Default

    Download Links:
    Links are hidden from guests. Please register to be able to view these links. Well, I'm guessing the cin function reads input according to the format of the variable set, so the variable ip should contain the address/domain you entered. Check that by just reading and then writing out that variable to screen.
    I'm also guessing that the system function executes the command line specified by a pointer (to the beginning of a string, if you're lucky). The strcat joins two strings, and returns a pointer to the crated string. (Note the added include line). I think this should work, if there aren't that big differences between C and C++.

  9. #9
    Join Date
    Apr 2005
    Location
    Pennsylvania, USA
    Posts
    520
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If you're starting C++ i'll wait for you to find out and keep trying... I have no clue how to use that. If you get into C++ and find out, reply here for future refference...

  10. #10
    Join Date
    Jan 2002
    Location
    Newcastle - UK
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You could try using the string class in the STL. I haven't tested this yet but it should work.

    Download Links:
    Links are hidden from guests. Please register to be able to view these links.
    <img src='http://www.emuparadise.org/vbulletin/attachment.php?s=&postid=318282'><br>

  11. #11
    Join Date
    Apr 2005
    Location
    Pennsylvania, USA
    Posts
    520
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ah, so that's how you add to a string... now... too add to that i would do...

    Download Links:
    Links are hidden from guests. Please register to be able to view these links. ?

  12. #12
    Join Date
    Feb 2005
    Location
    Limbo
    Posts
    3,706
    Thanks
    0
    Thanked 2 Times in 2 Posts
    EP Points
    10

    Default

    Well, that works in Macromedia Flash, where the ActionScript is much like C++, heavily object-dependent, even syntax, and most commands are taken from C++. BTW, my first suggestion was that you'd do that...
    Try that, if it works, it works.

  13. #13
    Join Date
    Jan 2005
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    EDIT: Thanks for the censorship, Cyber
    Last edited by Slick William; 23rd-June-2005 at 20:35.

  14. #14
    Join Date
    Apr 2005
    Location
    Pennsylvania, USA
    Posts
    520
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    cplusplus.com... sounds like the place where i got the tutorial that i use... =p

    action script and C++ are alike? hm... sounds convenient.

    Actually, pkt.... the difference between your first sugestion was the absence of #include "string". I was compleatly unaware of my headers and what they do. I always will be. lol that's the problem with C++. No one tells you anything accept the structer of how to use it if you find out what you have.

Similar Threads

  1. Whats your best char in SSBM?
    By Moofis in forum General Gaming
    Replies: 27
    Last Post: 23rd-February-2004, 00:55

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About Us

We are the oldest retro gaming forum on the internet. The goal of our community is the complete preservation of all retro video games. Started in 2001 as EmuParadise Forums, our community has grown over the past 18 years into one of the biggest gaming platforms on the internet.

Social