string header

This is a discussion on string header within the C++ Programming forums, part of the General Programming Boards category; i dont know if anyone experienced this with c++ 6.0 but there is know header called "string". does anyone know ...

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

    Question string header

    i dont know if anyone experienced this with c++ 6.0 but there is know header called "string". does anyone know how to solve this problem??
    if anyone can please give me the contents of the header and ill make it my self.

  2. #2
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    what do you mean the header "string" is a problem.
    I started out with nothing and I still have most of it left.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    2
    Code:
    #include <iostream.h>
    #include <stdio.h>
    #include <string.h>
    
    void main();
    {
    	
    	cout<<"a";
    	return 0;
    	
    }
    and it gives me 1 error

    error C2447: missing function header (old-style formal list?)

    although im starting to think that it isnt the string header.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,671
    Not only is void main wrong, I'm sure the ; at the end of the line has something to do with it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Besides void main:
    #include <iostream.h>
    Non standard header
    When compiling as C++
    #include <stdio.h>
    #include <string.h>
    Should be:
    Code:
    #include <cstdio>
    #include <cstring>

  6. #6
    Never Exist Hermitsky's Avatar
    Join Date
    Jul 2004
    Posts
    149
    Code:
    #include<iostream>
    #include<string>
    using namespace std;
    int main()
    {
    string mystring="Hello world !";
    cout<<mystring<<endl;
    return 0;
    }
    a standard sample of using cout function and c++ string type.
    i wonder if it is what you need
    because i can't get what you mean.....

    blow me ... ...

  7. #7
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Lightbulb About strings....

    revoletion, here are some things that you should know about strings:

    In C++, there are two types of strings and three string-headers.

    C-style strings (also called character arrays, or null-terminated strings), are simply an array of ASCII characters with a null (zero) at the end. Note that zero does not represent a printable ASCII character. A zero is represented by a decimal value of 41.... send 41 to your printer and it prints a zero!

    You do not need to include any headers to use C-style strings in your program. The code you posted doesn't need it. The two headers <cstring> and the "old" <string.h> are essentially identical. They have handy functions for mainipulating C-style strings. The cprogramming.com string tutorial uses C-style strings and <cstring>.

    Hermitsky's example uses a C++ string object which requires the <string> header. The <string> header contains a set of functions for manipulating string objects. (These functions are completely different than the functions in <cstring>.) C++ string objects are generally easier to use (and safer) than C-style strings, but they are more complex "under the hood".


    if anyone can please give me the contents of the header and ill make it my self.
    The three string headers are standard, and are included with every C++ compiler. You cannot generally mix-and-match header files between compilers. There is some information about this in the Programming FAQ.

    Just for fun, here are the string header files for the open-source Watcom compiler: (I added the .txt extension so that they all could be uploaded.)
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  3. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  4. Replies: 4
    Last Post: 03-03-2006, 01:11 AM
  5. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 09:33 PM

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