Thread: C++ Strings in Linux

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    5

    C++ Strings in Linux

    Hi,
    I've made a program that uses the string class, it works as intended except that part of the work that I've been set is to test the program in Linux. Unfortunately when I compile it in Linux it gets a whole load of errors, I have been told that this is because Linux doesn't support this string class and that I should use char arrays instead. Is this correct, and is there any way around it? I'm using functions from the string class so I'd rather not have to rewrite every time I use a string. Thanks in advance.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Linux (or more specifically gcc) supports C++ which includes the string class. What command are you using to compile the program?
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    Linux supports standard C++ strings.

    What errors are you getting? Are you including the proper include files? Show a sample of the code you are trying to compile that has errors.

    Jim

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    5
    I am using gcc -o to compile it.
    I've included these libraries:
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <sstream>
    The whole code is just errors. The errors had char repeated in them a lot. I don't have the errors on me right now but I am currently installing ubuntu so I should do in a minute.

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    First make sure that the C++ compiler is installed, it might not be installed automatically. Second to compile a C++ program you should be using g++ not gcc.

    Jim

  6. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    5
    Thanks that worked, it was just the wrong compiler then. Thanks guys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Back from the depths of Linux
    By SpEcIeS in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 03-03-2005, 12:09 PM
  2. Linux
    By cerin in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 02-10-2005, 09:41 PM
  3. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM
  4. Linux for Windows!
    By Strut in forum Linux Programming
    Replies: 2
    Last Post: 12-25-2002, 11:36 AM
  5. Linux? Windows Xp?
    By VooDoo in forum Linux Programming
    Replies: 15
    Last Post: 07-31-2002, 08:18 AM