Thread: Conversion from C++ to C

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    8

    Conversion from C++ to C

    I need a conversion of this line from C++ to C

    Code:
    cin.getline(testStr[i],80, '\n');
    also...can someone tell me if "qsort" works with -gcc


    -Thanx

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    99
    fgets(teststr, 80, stdin)

    yes

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    8
    hey thanx...can you help me with one more conversion...

    Code:
    cout << testStr[i][j];
    i need to know how to printf an array...
    i used:

    Code:
    printf ( testStr[i][j]);
    gave me some kinda..<null> error...or some kinda funky error


    -thanx

  4. #4
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    I'm guessing at how your storing. A 2d array?

    printf("%s", testStr[i]);

    [edit]

    char testStr[5][81];

    for(i=0; i < 5; i++)
    fgets(testStr[i], 81, stdin);

    for(i=0; i < 5; i++)
    printf("%s", testStr[i]);

    Should work for 2D arrays.

    [/edit]
    Last edited by ronin; 04-04-2003 at 02:13 PM.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    8
    yea...2D array

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  4. Do I have a scanf problem?
    By AQWst in forum C Programming
    Replies: 2
    Last Post: 11-26-2004, 06:18 PM
  5. Creation of Menu problem
    By AQWst in forum C Programming
    Replies: 8
    Last Post: 11-24-2004, 09:44 PM