Thread: Program unable to print anything

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    50

    Program unable to print anything

    Hi I have small pro c program

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <sqlda.h>
    #include <sqlcpr.h>
    
    int main()
    {
    
    
    char ch;
    int sal;
    
    
    EXEC SQL BEGIN DECLARE SECTION;
    
    char oracleid[20] = "scott/lion";
    
    EXEC SQL END DECLARE SECTION;
    
    
    
    
    printf("Connected to Oracle8i using Scott/Tiger\n");
    
    
    EXEC SQL CONNECT :oracleid;
    
    
    EXEC SQL WHENEVER sqlerror goto errexit;
    
    
    printf("Connected to Oracle8i using Scott/Tiger\n");
    
    
    
    errexit:
    
     printf("Connection failed");
    
    
    }
    To compile this program i used following commands in cygwin


    $ORACLE_HOME/bin/proc test.pc
    cc -I${ORACLE_HOME}/precomp/public -c test.c
    cc -o test test.o -L $ORACLE_HOME/precomp/lib -l orasql11

    With above command program is compiling and linking fine. But when i am running the exe, it is not printing anything. Even if it is not printing the printf statement at the very begining of the code

    Can anybody help why this is happening

    Thanks
    Sas

  2. #2
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    1) Indentation is not optional. 2) int main means that main must return an int, put "return 0;" at the expected end of main. 3) Are you sure it's not printing and exiting faster than you can see?

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I don't know what your first "EXEC SQL BEGIN DECLARE" section does, but it could be hanging right there and never actually reaching the first printf. So what actually happens when you run it? Does it just terminate back to the command prompt immediately, or does it just sit there?


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    50
    Yes..Even if i have written printf and scanf statement, the progrom didn't display anything..

    Thanks
    Sas
    Last edited by SasDutta; 07-22-2010 at 09:24 PM.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    50
    Yes..It is terminating back to the command prompt immediately..

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Lemme guess

    You typed
    test

    Rather than
    ./test


    test is a standard Unix/Linux tool to evaluate expressions for the shell.
    UNIX man pages : test ()
    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.

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    50
    No..I typed ./test

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > printf("Connection failed");
    a) print a newline as well.
    b) make sure main returns proper EXIT_SUCCESS / EXIT_FAILURE values, rather than just falling off the end.

    When it does return, print the exit status from the shell.
    ./test
    echo $?
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 05-30-2010, 10:22 PM
  2. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  3. Why is it that my program does not print for case 1?
    By Jasper in forum C Programming
    Replies: 10
    Last Post: 07-02-2009, 12:57 PM
  4. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM