From: Randy Decker <randydecker@earthlink.net>
To: Cygwin@cygwin.com
Subject: Executable from x86_64-w64-mingw32-gcc.exe waits for input before prompt in Cygwin terminal but not Win Command Prompt
Date: Sun, 12 Apr 2015 00:15:00 -0000 [thread overview]
Message-ID: <29768395.1428797734177.JavaMail.root@mswamui-valley.atl.sa.earthlink.net> (raw)
# Brief problem description
# C source file - 'printf("Test");' added as diagnostics
# Source compiles and executes in Ubuntu
# Executable compiled in cygwin terminal OK in command prompt W8.1
# - Also OK in another machine running Windows 8.1
# Same executable in cygwin term waits for input before usage hint
FROM CYGWIN64 TERMINAL
Randy@Hartford ~
$ cat countbytes.c
/* This program counts the number of bytes in a C source file.
The program prompts the user for a file name and then concatenates
the ".c" extension to this name. It uses the function getc to read
the characters.
program from "Applications Programming in ANSI C" by
Hohnsonbaugh & Kalin
*/
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
main( )
{
FILE* fptr;
char extension[] = ".c";
int char_count;
printf("Test");
printf("\n\n\tFile name (NO extension):\t");
char file_name[FILENAME_MAX]; /* defined in stdio.h*/
scanf("%s",file_name);
strcat(file_name,extension);
fptr=fopen(file_name,"rb");
for(char_count=0; getc(fptr) !=EOF; ++char_count);
printf("\n\tByte size:\t%d", char_count);
printf("\n");
fclose(fptr);
return EXIT_SUCCESS;
}
# Confirm Countbytes.exe not yet here
Randy@Hartford ~
$ ls -a
. .swp myhello.exe
.$$$ countbytes.c myhello2.exe
.. countem.exe myhelloworld.c
.bash_history countem3.exe testc.c
.bash_profile countemm.exe testit.exe
.bash_profile_temp countemm2.exe testittestc.exe
.bash_profileWin.txt countOnUbuntu.txt testtext.txt
.bashrc cygwinResults.txt welcome.exe
.bashrc_ORG Hello.c x86_64-w64-mingw32-gcc.exe
.inputrc HelloFromUnix.c
.profile HelloFromUnix-PFEvsNotepad.c
# Show alias
Randy@Hartford ~
$ alias
alias gcc='C:/cygwin64/bin/x86_64-w64-mingw32-gcc.exe'
# Compile the program
Randy@Hartford ~
$ gcc -o countbytes countbytes.c
# Verify countbytes.exe now exists
Randy@Hartford ~
$ ls
countbytes.c cygwinResults.txt Progress_Notes.txt
->countbytes.exe Hello.c testc.c
countem.exe HelloFromUnix.c testit.exe
countem3.exe HelloFromUnix-PFEvsNotepad.c testittestc.exe
countemm.exe myhello.exe testtext.txt
countemm2.exe myhello2.exe welcome.exe
countOnUbuntu.txt myhelloworld.c x86_64-w64-mingw32-gcc.exe
# Execute the output in cygwin64 terminal. Program waits with no output
# Until enter is pressed on a non blank line.
Randy@Hartford ~
$ ./countbytes
countbytes
Test
File name (NO extension):
Byte size: 865
Randy@Hartford ~
# Demonstrate same files as Cygwin64 Terminal
FROM WINDOWS 8.1 COMMAND PROMPT
Directory of C:\cygwin64\home\Randy
[.] [..]
.$$$ .bashrc
.bashrc_ORG .bash_history
.bash_profile .bash_profileWin.txt
.bash_profile_temp .inputrc
.profile .swp
countbytes.c ->countbytes.exe
countem.exe countem3.exe
countemm.exe countemm2.exe
countOnUbuntu.txt cygwinResults.txt
Hello.c HelloFromUnix-PFEvsNotepad.c
HelloFromUnix.c myhello.exe
myhello2.exe myhelloworld.c
Progress_Notes.txt testc.c
testit.exe testittestc.exe
testtext.txt welcome.exe
x86_64-w64-mingw32-gcc.exe
31 File(s) 1,289,107 bytes
2 Dir(s) 142,941,614,080 bytes free
# Execute the output in Windows command prompt terminal.
# Program PRINTS " File name (NO extension):"
# then waits Until filename is entered.
# NOTE: Execution of same code in Ubuntu 14.4 works like this.
C:\cygwin64\home\Randy>countbytes
Test
File name (NO extension): countbytes
Byte size: 865
C:\cygwin64\home\Randy>
--
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
next reply other threads:[~2015-04-12 0:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-12 0:15 Randy Decker [this message]
2015-04-12 8:53 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=29768395.1428797734177.JavaMail.root@mswamui-valley.atl.sa.earthlink.net \
--to=randydecker@earthlink.net \
--cc=Cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).