This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems with "Hello, World!"


Am 19.03.2019 um 22:31 schrieb Vesa P.:
Hi all,

Cygwin works great for me in providing POSIX tools for Windows, but
when I tried to to compile something of my own, I immediately ran into
problems.

Compiling my Hello World application didn't complain but when running
it I didn't get any output. My compilation command was like this:
    gcc -Wextra -Wall -o hello hello.c
And my source code is below between "---" markers:
----------------------------------
#include <stdio.h>

int main() {
   printf("Hello, World!\n");
   return 0;
}
----------------------------------
I also tried by redirecting output, like "./hello > output.txt" but
that created only an empty file, proving that my write permissions
were sufficient, I suppose.
Then I thought that maybe the problem is in connecting to stdout and I
tried by direct file access:
---------------------------------
#include <stdio.h>

int main() {
   FILE *of = fopen("./outfile.txt", "w");
   if(of) {
     fprintf(of, "Hello, World!\n");
     fclose(of);
   }
   return 0;
}
---------------------------------
However, that didn't create the "outfile.txt" file.
What does `type gcc` tell you?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]