Replacement for Console.WriteLine?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ramon F Herrera

    Replacement for Console.WriteLine?


    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.GetFieldIte rator();

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

    Since my g++ compiler doesn't like the "Console.WriteL ine()"
    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


  • Christopher

    #2
    Re: Replacement for Console.WriteLi ne?

    On Mar 6, 3:55 pm, Ramon F Herrera <ra...@conexus. netwrote:
    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.GetFieldIte rator();
    >
    while (itr.HasNext()) {
    Field field = itr.Current();
    Console.WriteLi ne("Field name: {0}", field.GetName() );
    itr.Next();
    }
    >
    Since my g++ compiler doesn't like the "Console.WriteL ine()"
    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;
    }

    Comment

    Working...