Output "problem"

This is a discussion on Output "problem" within the C++ Programming forums, part of the General Programming Boards category; Is there anyway is make text contained within quotation marks appear in a display? Code: cout<<"He said "bla bla" and ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    2

    Output "problem"

    Is there anyway is make text contained within quotation marks appear in a display?

    Code:
    cout<<"He said "bla bla" and they all laguhed";
    ^^ bla bla will cause an error.

    My idea is a .html generator and HTML code contains alot of "s which is screwing up my output as this unfinished code shows below:

    Code:
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    int main() {
        
        char name[15], email[50], bio[255], image1[25], image2[25], image3[25], image4[25], eyes[10], hair[20], height[10], age[10];
        int imgno;
        ifstream index (index.html);
        ifstream biog (biography.html);
        ifstream pict (pictures.html);
        
        cout<<"////////////////////////////////////////////////////////////////////\n";
        cout<<"Weclome To The Duddle.Co Personal Web Creator"\n;
        cout<<"////////////////////////////////////////////////////////////////////\n\n";
        cout<<"Please take the time to provide us with a few details so we can\n create a personal website just for you\n";
        cout<<"First Name: ";
        cin>>name;
        cout<<"Your D.O.B (dd/mm/yyyy): "
        cin>>age;
        cout<<"\nYour E-Mail Address: ";
        cin>>email;
        cout<<"\nEye Colour: ";
        cin>>eyes;
        cout<<"\nHair Colour: ";
        cin>>hair;
        cout<<"\nYour Height: ";
        cin>>height;
        cout<<"\n\nHow many images would you like to have on you webpage (max 4): "
        cin>>imgno;
        
        if (imgno=1) {
        cout<<"Please enter the name of the image (without the extention): ";
        cin>>image1;
        }
        if (imgno=2) {
        cout<<"Please enter the name of the FIRST image (without the extention): ";
        cin>>image1;
        cout<<"Please enter the name of the SECCOND image (without the extention): ";
        cin>>image2;
        }
        if (imgno=3) {
        cout<<"Please enter the name of the FIRST image (without the extention): ";
        cin>>image1;
        cout<<"Please enter the name of the SECCOND image (without the extention): ";
        cin>>image2;
        cout<<"Please enter the name of the THIRD image (without the extention): ";
        cin>>image3;
        }
        if (imgno=4) {
        cout<<"Please enter the name of the FIRST image (without the extention): ";
        cin>>image1;
        cout<<"Please enter the name of the SECCOND image (without the extention): ";
        cin>>image2;
        cout<<"Please enter the name of the THIRD image (without the extention): ";
        cin>>image3;
        cout<<"Please enter the name of the FOURTH image (without the extention): ";
        cin>>image4;
        }
        index<<"<html>\n\n<head>\n<meta http-equiv="Content-Language" content="en-gb">\n<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">\n<meta name="GENERATOR" content="Microsoft FrontPage 4.0">\n<meta name="ProgId" content="FrontPage.Editor.Document">\n<title>New Page 1</title>\n</head>\n\n<body>\n\n<p align="center"><font size="7"><u><b>Name's Homepage</b></u></font></p>\n<p align="left"><font size="4">Welcome to my homepage, a website all about me\nand my interests. Feel free to brows around and send any comments you have to my\nE-mail address: <a href="mailto:email@msn.com">email@msn.com</a> </font></p>\n<p align="left"><font size="4"><a href="biography.html">Biography</a></font></p>\n<p align="left"><font size="4"><a href="pictures.html">Pictures</a></font></p>\n\n</body>\n\n</html>\n
    }

  2. #2
    Bioport Productions
    Join Date
    Oct 2005
    Posts
    215
    Yes, the \ is the escape character in C++. If the character following the escape charater isn't a valid escape code, the character will be shown. for example:

    cout<<"My mom said \"Eat your soup\n and peas\"."; // n is the escape character for newline so the n isn't shown

    you could also put '\' in your string by putting \\.
    -"What we wish, we readily believe, and what we ourselves think, we imagine others think also."
    PHP Code:
    sadf 

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    2
    Thanks alot, quick reply too

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 02:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 02:29 PM
  3. Replies: 4
    Last Post: 11-30-2005, 03:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21