Replacement for Console.WriteLine?

Discussion in 'C++' started by Ramon F Herrera, Mar 6, 2008.

  1. I am an experienced C developer, but also a newbie in C++.

    I am trying to compile and run the following code snippet on Linux:

    FieldIterator itr = doc.GetFieldIterator();

    while (itr.HasNext()) {
    Field field = itr.Current();
    Console.WriteLine("Field name: {0}", field.GetName());
    itr.Next();
    }

    Since my g++ compiler doesn't like the "Console.WriteLine()"
    statement, I googled for it, and it seems to be some Windows-specific
    construct. What can I use as a replacement? Obviously, I tried
    "printf()" but the argument is not a string.

    TIA,

    -RFH
    Ramon F Herrera, Mar 6, 2008
    #1
    1. Advertising

  2. Ramon F Herrera

    Christopher Guest

    On Mar 6, 3:55 pm, Ramon F Herrera <> wrote:
    > I am an experienced C developer, but also a newbie in C++.
    >
    > I am trying to compile and run the following code snippet on Linux:
    >
    > FieldIterator itr = doc.GetFieldIterator();
    >
    > while (itr.HasNext()) {
    > Field field = itr.Current();
    > Console.WriteLine("Field name: {0}", field.GetName());
    > itr.Next();
    > }
    >
    > Since my g++ compiler doesn't like the "Console.WriteLine()"
    > statement, I googled for it, and it seems to be some Windows-specific
    > construct. What can I use as a replacement? Obviously, I tried
    > "printf()" but the argument is not a string.
    >
    > TIA,
    >
    > -RFH


    I don't knwo what your "Field" or "doc" is, but it looks to me like
    you have .NET code there, not C++.
    To display something to the console, or more specifically to the
    standard out stream, use std::cout.
    You will have quite the time converting .NET to C++ on a Linux
    platform.

    #include <iostream>

    int main()
    {
    std::cout << "Hello World!";
    return 0;
    }
    Christopher, Mar 6, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grey

    Cannot use "Console.WriteLine"

    Grey, Apr 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,407
    =?Utf-8?B?U3VkaGFrYXIgU2FkYXNpdnVuaVtNVlBd?=
    Apr 13, 2004
  2. Flip
    Replies:
    6
    Views:
    6,656
    Jeff Dillon
    Nov 18, 2004
  3. Flip
    Replies:
    1
    Views:
    629
    Brock Allen
    Apr 14, 2005
  4. Replies:
    1
    Views:
    528
    john_teague
    Sep 1, 2005
  5. =?Utf-8?B?QUFPTSBUaW0=?=

    How can I redirect Console.Writeline to Response.Output?

    =?Utf-8?B?QUFPTSBUaW0=?=, Mar 21, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    636
    =?Utf-8?B?QUFPTSBUaW0=?=
    Mar 21, 2007
Loading...

Share This Page