Thread: what's wrong?

  1. #1
    Unregistered
    Guest

    Thumbs up what's wrong?

    I thought I had the best idea. It was to create a cheap lookin' HTML editor by creating a text file which had HTML code in it and place .html on the end to create it an HTML document. I wrote all of the code (including some cool comments in the HTML ) but...I got these <b>confusing</b> error messages from MSVC++. Here is the code:



    // tryin' to make a cheap-ass HTML editor...

    #include <iostream.h>
    #include <fstream.h>
    #include <string.h>
    #include <stdlib.h>

    int main()
    {
    cout << "***********************************************\n ";
    cout << " Welcome to ChrisHTML version 0.5\n";
    cout << "***********************************************\n ";
    cout << "\nThis program only sets the title, the background\n";
    cout << "colour and the text colour - don't expect anything\n";
    cout << "that slightly resembles an HTML editor at all becuase\n";
    cout << "Chris Pocock wrote this crap that you are looking at right now\n";

    char title[50];
    cout << "Enter the title for you page: ";
    cin.getline(title, 50);
    cout << "\n";

    unsigned bgcolor;
    cout << "Enter what colour-code for your background: ";
    cin >> bgcolor;
    cout << "\n";

    unsigned textcolor;
    cout << "Enter the colour for the text: ";
    cin >> textcolor;
    cout << "\n";

    ofstream output;

    output.open("ChrisHTML.html");

    output << "<!--Generated by ChrisHTML 0.5-->\n";
    output << "<HTML>\n";
    output << "<HEAD>\n";
    output << "<TITLE>";
    output << title;
    output << <TITLE>\n";
    output << "<meta name="GENERATOR" content="ChrisHTML 0.5">
    output << "</HEAD>";
    output << "<BODY ";
    output << bgcolor=";
    output << bgcolor;
    output << " text=";
    output << text;
    output << " >\n";
    output << "<h2>See source for main body<h2>\n";
    output << "\n<!--You know how cheap Chris is...he would never";
    output << "bother to actually let you create the main body of the";
    output << "document, so you are going to have to add it all yourself-->\";
    output << "</BODY>\n";
    output << "</HTML>\n";


    output.close;

    cout << "HTML page created...go take a look!\n";

    return 0;
    }



    ...and here are the errors



    Deleting intermediate files and output files for project 'HTML editor - Win32 Debug'.
    --------------------Configuration: HTML editor - Win32 Debug--------------------
    Compiling...
    main.cpp
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(42) : error C2059: syntax error : '<'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(42) : error C2017: illegal escape sequence
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(42) : error C2001: newline in constant
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2001: newline in constant
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(46) : error C2001: newline in constant
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(47) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'char [2]' (or there is no acceptable conversion)
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(47) : error C2146: syntax error : missing ';' before identifier 'output'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(54) : error C2001: newline in constant
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(55) : error C2146: syntax error : missing ';' before identifier 'output'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(59) : warning C4551: function call missing argument list
    Error executing cl.exe.

    HTML editor.exe - 9 error(s), 1 warning(s)



    Could somebody please help me

    Thanks heaps
    -Chris

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    oops!! forgot to sign in when i posted the above...

  3. #3
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Missing an opening quotation on this line

    output << <TITLE>\n";

    and this one as well

    output << bgcolor=";
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  4. #4
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    ok, I fixed those mistakes, but I still get the following errors:


    Deleting intermediate files and output files for project 'HTML editor - Win32 Debug'.
    --------------------Configuration: HTML editor - Win32 Debug--------------------
    Compiling...
    main.cpp
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2146: syntax error : missing ';' before identifier 'GENERATOR'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2065: 'GENERATOR' : undeclared identifier
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2143: syntax error : missing ';' before 'string'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2146: syntax error : missing ';' before identifier 'ChrisHTML'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2065: 'ChrisHTML' : undeclared identifier
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2143: syntax error : missing ';' before 'constant'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2001: newline in constant
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(43) : error C2143: syntax error : missing ';' before 'string'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(44) : error C2146: syntax error : missing ';' before identifier 'output'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(54) : error C2001: newline in constant
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(55) : error C2146: syntax error : missing ';' before identifier 'output'
    c:\program files\microsoft visual studio\myprojects\html editor\main.cpp(59) : warning C4551: function call missing argument list
    Error executing cl.exe.

    HTML editor.exe - 11 error(s), 1 warning(s)

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    19
    you've left out the '\' character before your " marks in the output, along with some ; characters. Here is the (hopefully) fixed code:

    output << "<!--Generated by ChrisHTML 0.5-->\n";
    output << "<HTML>\n";
    output << "<HEAD>\n";
    output << "<TITLE>";
    output << title;
    output << <TITLE>\n";
    output << "<meta name=\"GENERATOR\" content=\"ChrisHTML 0.5\">";
    output << "</HEAD>";
    output << "<BODY ";
    output << "bgcolor=";
    output << bgcolor;
    output << " text=";
    output << text;
    output << " >\n";
    output << "<h2>See source for main body<h2>\n";
    output << "\n<!--You know how cheap Chris is...he would never";
    output << "bother to actually let you create the main body of the";
    output << "document, so you are going to have to add it all yourself-->\";
    output << "</BODY>\n";
    output << "</HTML>\n";

    still, a good idea indeed ...definitely worth an extension (i.e. frames page option / number of headers, etc.)...and also one to output the 'generated' code to a file.

    Peter Kimberley
    [email protected]

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    19
    didn't post correctly: should be that the \ character is inserted before each " in the output stream.

  7. #7
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    I don't understand, could you please show me how (where the you put the "\"?)

  8. #8
    Unregistered
    Guest
    You have to put a \ infront of all the " you want to output into the file. Otherwise the compiler will think that the string ends there. Get it?

    cout <<" Here's an "Example"";

    That wouldn't work, the compiler would think that " Here's an " is a string, Example isn't, and then "" is a string again. Insted, you should do this:

    cout <<"Here's an \"Example\"";

    Now the compiler would print out "Here's an "Example".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM