Thread: exercises

  1. #1
    Registered User
    Join Date
    Dec 2011
    Location
    Eindhoven, Noord-Brabant, Netherlands
    Posts
    54

    exercises

    Just finished the first chapter of accelerated c++. There is this exercise i'm unable to complete.
    Here it goes: 'I need to write a program that writes: This is (") a double quote. 'I just dunno how to do it.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Look on the previous page: there is a paragraph on string literals.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The escape sequence to produce a double quote is \". Place that escape sequence in string or character literals, as needed.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    Registered User
    Join Date
    Dec 2011
    Location
    Eindhoven, Noord-Brabant, Netherlands
    Posts
    54
    Quote Originally Posted by grumpy View Post
    The escape sequence to produce a double quote is \". Place that escape sequence in string or character literals, as needed.
    Thx, but hoe do i That? Can u please gimme an example?

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    std::string Hello = "\"Hello World!\""; // <-- Stores "Hello World!" (with quotes)
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Dec 2011
    Location
    Eindhoven, Noord-Brabant, Netherlands
    Posts
    54
    Quote Originally Posted by Elysia View Post
    std::string Hello = "\"Hello World!\""; // <-- Stores "Hello World!" (with quotes)
    Thz, but it ain't workin. It does work with words, but when i use double quotes, it does'n work.

  7. #7
    Registered User
    Join Date
    Dec 2011
    Location
    Eindhoven, Noord-Brabant, Netherlands
    Posts
    54
    I figured it out, im a genius, hahaahahahah.

  8. #8
    Registered User
    Join Date
    Dec 2011
    Location
    Eindhoven, Noord-Brabant, Netherlands
    Posts
    54
    I would like to take my time to tell u guys this: Look, i am really sick, i always end up at the hospital, most of the times @emergency. I take these medicines against mental illness, and the one i'm currently takin, makes it impossible to learn. SO when i get better, i try to teach myself programming, but it just doesn't work cuz of the damn medicines.
    I give up out of frustration, but then i try to learn again. That's is the reason y i keep comin back and askin the same damn questions over and over again. I jut hope this time I get medicines that actually make me able to learn properly.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Next time, if it doesn't work, then show us your code, so we can see exactly why it doesn't work. Compile errors, if you get any, are helpful too.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Kuro Tensai View Post
    I would like to take my time to tell u guys this: Look, i am really sick, i always end up at the hospital, most of the times @emergency. I take these medicines against mental illness, and the one i'm currently takin, makes it impossible to learn. SO when i get better, i try to teach myself programming, but it just doesn't work cuz of the damn medicines.
    I give up out of frustration, but then i try to learn again. That's is the reason y i keep comin back and askin the same damn questions over and over again. I jut hope this time I get medicines that actually make me able to learn properly.
    I really don't know what to tell you dude. I'm personally not comfortable with being guilt tripped into teaching someone anything. Even if you can't go outside without exploding I can't take responsibility for how well you learn things.

    How to Properly Research Online (and Not Embarrass Yourself with the Results)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Exercises
    By GReaper in forum C++ Programming
    Replies: 11
    Last Post: 07-17-2010, 01:22 PM
  2. exercises in c++
    By BEN10 in forum C++ Programming
    Replies: 2
    Last Post: 07-26-2008, 04:07 AM
  3. C# Exercises
    By Rainbowinblack in forum C# Programming
    Replies: 0
    Last Post: 01-17-2008, 01:47 PM
  4. C++ Exercises
    By lasher in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2006, 09:48 PM
  5. Exercises
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-14-2001, 11:29 AM