Thread: Works in windows but not in debian

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    4

    Question Works in windows but not in debian

    Hello everyone. I was wondering if anyone has ever came across this issue.
    Code:
    #include <stdio.h>
    
    main(){
    printf("Testing");
    }
    When running this code in windows everything works great. When doing so in Linux it runs but doesn't output anything to the screen. I've been searching Google for some time now but can't seem to find a solution to solve this. Thanks in advance to anyone that can help. I am about to start my advanced programming class in Jan and want to get up to par with my C skills so it's imperative to get this working in linux.

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Please give some more details..
    Like how you're compiling it...and where you're running it from.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    You're not printing a newline ('\n') at the end of the string.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by seanfmglobal View Post
    When running this code in windows everything works great. When doing so in Linux it runs but doesn't output anything to the screen.
    It does if you compile and run it exactly as you posted, but I think you have paraphrased See brewbuck's point; this has to do with flushing the stdout buffer (it also gets flushed on a clean exit).

    I am about to start my advanced programming class in Jan and want to get up to par with my C skills so it's imperative to get this working in linux.
    By the C standard, main() returns an int. You should compile with warnings enabled:

    gcc -Wall mycode.c

    and it would have told you, "warning: control reaches end of non-void function".
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    is your program called 'test' by any chance?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rebuilding Debian AMD64 with ACPI/APM support, Debian DRI on XFree86
    By kawk in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 06-02-2006, 01:36 PM
  2. Windows XP and Debian GRUB
    By kawk in forum Tech Board
    Replies: 5
    Last Post: 03-26-2006, 06:09 PM
  3. This works on linux...but why not windows?
    By Kinasz in forum C Programming
    Replies: 6
    Last Post: 12-29-2005, 04:50 PM
  4. How come this only works in Windows nt/2000?
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 08-30-2002, 06:54 PM
  5. Replies: 6
    Last Post: 01-07-2002, 02:46 AM

Tags for this Thread