Fuction Headers

This is a discussion on Fuction Headers within the C++ Programming forums, part of the General Programming Boards category; doing that only caused one error: fatal error C1083: Cannot open include file: 'cstring.h': No such file or directory [edit]I ...

  1. #16
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    cool

    doing that only caused one error:

    fatal error C1083: Cannot open include file: 'cstring.h': No such file or directory

    [edit]I just downloaded cstring and it has thew 69 errors again[edit]
    Last edited by makit; 06-11-2002 at 12:39 PM.

  2. #17
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    Well, i've been looking at your code and there's something there I don't know what it is...

    getline(cin, name); <-- I never used it this way.

    cin.getline (name, 256, '\n'); <-- this is the way I normally use it.

    If those errors are relating to the lines wher you have those getline's then you should change them (replace 'name' with the variable name you are using at the moment):

    getline(cin, meta);

    becomes

    cin.getline (meta, 256, '\n');

    Don't change them all... just a couple and recompile to check if the errors for those lines numbers you change do dissapear.
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  3. #18
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    ummmmm...

    well I changed one of them and there was still 69 errors so that can't be an error. Also I get this error:

    '=' : cannot convert from 'char [8]' to 'int'

    which is on the first string line (string font="Default" there are lots of these but how come I only get one error when I had:

    int string, main();

    and not

    int main()

    ??

  4. #19
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    Contrary to other toy languages, number of errors in a C++ compiler is not an indication of how close you are of having a error free code
    You can have a gazillion errors and one simple line of code will solve all of them. Conversely you can have only one error and be miles away of finishing the code, simply because the compiler stopped at that error.

    The line int string main(); was an error. int is a datatype. Since you included <string>, string becomes also a datatype and as such you were declaring main to return an int and a string... you can only return one datatype from a function. Also, the semicolon at the end was defining main as a prototype. But you don't prototype main(). That function is a special function and should always be declared as int main(). (In fact there's another form for it... but nothing to do with return types).

    Most probably you only get one error simply because the compiler stops right at that error.

    I'm afraid I can't help you anymore
    It seems to me that code you got is full of errors... my advice, since you are just starting to learn, is to read C++ tutorials and work yourself up from there. Downloading a lenghty piece of code will help you in no way as copy/paste is an enemy of any student.
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  5. #20
    Registered User
    Join Date
    Jun 2002
    Posts
    15
    anyways thanks for your help

  6. #21
    Registered User
    Join Date
    Feb 2002
    Posts
    591
    The problems you are having with strings in your code is beacause the namespace handling is incorect. I don't have all of your code but this works
    Code:
    #include <string>
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    void menu() 
    { 
    system("cls"); 
    cout << "******************************\n"; 
    cout << "1.) Insert an Image\n"; 
    cout << "2.) Insert an Image Link\n"; 
    cout << "3.) Insert Text\n"; 
    cout << "4.) Insert Text Link\n"; 
    cout << "5.) Change Font\n"; 
    cout << "6.) Change Font Size\n"; 
    cout << "7.) Change Font Color\n"; 
    cout << "8.) Insert Horizontal Line\n"; 
    cout << "9.) Insert a Break\n"; 
    cout << "10.) Exit WebpageMakerv.1.1\n"; 
    cout << "******************************\n"; 
    } 
    
    
    int main() 
    { 
    	string font="Default"; 
    	string fontsize="Default"; 
    	string fontcolor="Default"; 
    	string text; 
    	string hrcolor; 
    	string align; 
    	string address; 
    	string alink; 
    	string vlink; 
    	string link; 
    	string path; 
    	string color; 
    
    	return 0;
    }
    Last edited by Barjor; 06-11-2002 at 01:59 PM.

  7. #22
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    how

    how do i declare a identifier? I have changed what you said and now I only have one error saying undeclared identifier so I want to fox it

  8. #23
    Registered User
    Join Date
    Feb 2002
    Posts
    591

    Talking

    How about posting the code that gives you that error?

  9. #24
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    If it isn't too long, try rewriting the whole code, and compile and run every time you add something in. That is what you should learn to do ATM. But after you get accustomed to C++, you can slow down on compiling, since you know your code is basically bug-free, however, there is always bugs just about, except for something like hello, world.

  10. #25
    Registered User
    Join Date
    Feb 2002
    Posts
    98

    convert from old style to new style!

    are you writting code out of an older book for msvc++ 5, and using it in msvc++6?is it a msvc++5 book that came with a learning cd? if so, try opening the project your trying to use and it will update it to the new format for you. im a newbie, reading out of a book written for msvc++5, when i write the code straight out of the book, it gives me the same errors, but when i open the same project in msvc++6 from the disk, it ask me if i want to update it to the new format, fixes the problem anyways.i just begun to learn the differances from msvc++5 and 6, but they are probly a lot, i didnt see any of the stuff in your code that was differant, but its worth a shot.

  11. #26
    Registered User
    Join Date
    Jun 2002
    Posts
    15
    Error:

    (65) : error C2065: 'getch' : undeclared identifier

    start of code:

    #include <string>
    #include <iostream>
    #include <fstream>

    using namespace std;

    void menu()
    {
    system("cls");
    cout << "******************************\n";
    cout << "1.) Insert an Image\n";
    cout << "2.) Insert an Image Link\n";
    cout << "3.) Insert Text\n";
    cout << "4.) Insert Text Link\n";
    cout << "5.) Change Font\n";
    cout << "6.) Change Font Size\n";
    cout << "7.) Change Font Color\n";
    cout << "8.) Insert Horizontal Line\n";
    cout << "9.) Insert a Break\n";
    cout << "10.) Exit WebpageMakerv.1.1\n";
    cout << "******************************\n";
    }


    int main()
    {
    string font="Default";
    string fontsize="Default";
    string fontcolor="Default";
    string text;
    string hrcolor;
    string align;
    string address;
    string alink;
    string vlink;
    string link;
    string path;
    string color;

    string name;
    string title;
    string meta;
    cout << "~ Welcome to MaKiT Webpage Maker 1.0 ~\n";
    cout << "\nPlease enter a filename.html: ";
    getline(cin, name);
    ofstream kcout(name.c_str());
    kcout << "<html>\n<head>\n"
    <<"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">";
    cout << "Please Enter The Key words That Search Engines Will use to Describe Your page:\n";
    getline(cin,meta);
    kcout<<"\n<META NAME=\"keywords\" CONTENT=\""<<meta<<"\">\n";
    cout <<"\n\nPlease input a Description of you website:\n";
    getline(cin, meta);
    kcout << "<META NAME=\"description\" CONTENT=\""<<meta<<"\">\n";
    cout << "\n\nWhat is your Name: (Who is the author of this page)\n";
    getline(cin,meta);
    kcout << "<META NAME=\"author\" CONTENT=\""<<meta<<"\">\n";
    cout << "Press any key to continue...\n";
    system("cls");
    kcout << "\n<title>\n";
    cout << "What is the title of your WebPage: ";
    getline(cin ,title);
    kcout << title<<"\n</title>\n</head>\n";
    cout << "Press any key to continue...\n";
    getch();
    system("cls");
    cout << "Do you wish to have a picture or color for your background?\n";
    cout << "Type p or c here: ";
    string background;
    getline (cin ,background);
    cout << "Press any key to continue...\n";
    getch();
    system("cls");
    if (background=="p")
    ...

  12. #27
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    Add the following line to the include's part of your code:

    #include <curses>
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  13. #28
    Registered User
    Join Date
    Jun 2002
    Posts
    15

    can?

    I dont have the curses header file. Can you tell me a site. please, where I can download header files?

  14. #29
    Unregistered
    Guest
    Try writing your headers like this:

    Code:
    #include <string>
    
    using namespace std;
    
    #include <iostream.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <fstream.h>
    #include <stdio.h>

  15. #30
    Registered User
    Join Date
    Jun 2002
    Posts
    15
    i dont have the header file so that wont work!

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 06-18-2005, 02:26 PM
  2. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  3. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  4. Precompiled Headers, are they necessary?
    By XenoCodex Admin in forum C++ Programming
    Replies: 2
    Last Post: 06-23-2002, 02:09 PM

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