Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 4th, 2005, 3:51 PM   #1
Insomniac
Programmer
 
Insomniac's Avatar
 
Join Date: Aug 2004
Location: Cloud #9
Posts: 47
Rep Power: 0 Insomniac is on a distinguished road
(SOLVED)It's giving me "Press any key to continue" and no other output..

I got this from About.

  #include <stdio.h>
  
  int main()
  {
  	int luckyNumber = 5;
  	float radius = 2;
  	char myName[15] = "John";
  	char initial = 'J';
  	
  	printf( "Hellow World!\n" ); /* the format string contains only o
 							 ordinary characters. Ordinary characters 
 							 are output unmodified.
 							 A character string in C is of type
 							 "char *".*/
  	
  	printf( "My lucky number is %d\n", luckyNumber ); /*The "%d" specifies
 							 that an integer value will be output.*/
  	
  	printf( "My name is %s\n", myName ); /* The %s specifies that a character
 							 string will be output.*/
  	
  	printf( "My first initial is %c\n", initial ); /*The %c specifies that a
 							 character will be output.*/
 							 
  	printf( "The area of a circle with radius %f is %f\n", radius, 3.14* radius*radius );
 								 //%f specifies that a float will be output
  	
  	printf( "Hello %s or should I say %c\n", myName, initial );
 							 //multiple arguments of different types may be output.
  	
  	getchar();
  	return(0);
  }

I realize there should be output with this program. I tried adding #include <iostream> and using namespace std; and changed all the printf to cout's with no success. After that I looked for grammatical errors. Then I used Google with the keyword "Press any key to continue" and even added "learning programming"(only not in quotes) to it. Nothing. I then did a search of the forums here and also found nothing. It seems like it should simply output something and I can't understand why.

Side note: My compiler occasionaly acts funny; freezing up, running high, rewriting words for me. I checked the help file and index and I have no clue why it's doing this.

Please help.

EDIT: Thanks you guys for the help. Ill attempt the database search and get the other version of DevC++ that DaWei suggested. Im not going to get too involved as my experience in this is low AND Ill be receiving a new system shortly, thus Ill put more effort into the new rig. I appreciate it.

Thanks.
__________________
From an IBM Thinkpad T43 - 14.1" SXGA+ - ATI 64 MB X300 - Sonoma 760 - 2 GB RAM - 80 GB HD 5400 - IBM ABG II - FC3, Ubuntu & XPee
DevC++, and Macromedia's - Dreamweaver & Flash Pro and a little Adobe Illustrator & Photoshop
Sleep? Sleep is for the weak.:cool:


Last edited by Insomniac; Jun 6th, 2005 at 6:05 PM.
Insomniac is offline   Reply With Quote
Old Jun 4th, 2005, 6:14 PM   #2
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 5 uman is on a distinguished road
this works fine on my computer.
uman is offline   Reply With Quote
Old Jun 4th, 2005, 6:19 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Totally uninstall your compiler and reinstall. Then try again. DevC++ has always performed well for me. If you have the same difficulties, then post back.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jun 4th, 2005, 7:26 PM   #4
Insomniac
Programmer
 
Insomniac's Avatar
 
Join Date: Aug 2004
Location: Cloud #9
Posts: 47
Rep Power: 0 Insomniac is on a distinguished road
I deleted it.. but, excuse me for asking this, does it necessarily have to go in the root directory? I originally put it in a c:\program files\personal folder but now Im thinking to put it in simply c:\
__________________
From an IBM Thinkpad T43 - 14.1" SXGA+ - ATI 64 MB X300 - Sonoma 760 - 2 GB RAM - 80 GB HD 5400 - IBM ABG II - FC3, Ubuntu & XPee
DevC++, and Macromedia's - Dreamweaver & Flash Pro and a little Adobe Illustrator & Photoshop
Sleep? Sleep is for the weak.:cool:

Insomniac is offline   Reply With Quote
Old Jun 4th, 2005, 8:18 PM   #5
Insomniac
Programmer
 
Insomniac's Avatar
 
Join Date: Aug 2004
Location: Cloud #9
Posts: 47
Rep Power: 0 Insomniac is on a distinguished road
My status is after placing the new Dev in the c:\ location, I ran the above program just fine. However, after running a few others and tinkering with them I later went back to the above program and Im now, once again, having the same "press any key to continue" message. I did not make any changes to it whatsoever. I simply left it alone, then went on to other programs, came back and it's putting up a fuss. I checked everything to make I was actually opening the correct program, and I am. Very strange...
__________________
From an IBM Thinkpad T43 - 14.1" SXGA+ - ATI 64 MB X300 - Sonoma 760 - 2 GB RAM - 80 GB HD 5400 - IBM ABG II - FC3, Ubuntu & XPee
DevC++, and Macromedia's - Dreamweaver & Flash Pro and a little Adobe Illustrator & Photoshop
Sleep? Sleep is for the weak.:cool:

Insomniac is offline   Reply With Quote
Old Jun 4th, 2005, 8:31 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
If it's displaying that message, it means the program's finished and Dev-C++ is executing the PAUSE command in the MS console. Basically, it sounds like your program's crashing. Unless the GCC developers decided to place a ban on misspellings of the word "Hello", I really can't see what the problem is.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jun 4th, 2005, 8:32 PM   #7
mitakeet
Programmer
 
mitakeet's Avatar
 
Join Date: Jun 2005
Location: Maryland, USA
Posts: 59
Rep Power: 4 mitakeet is on a distinguished road
Which program are you having problems with? The one you posted or the one you modified? You display a program using C IO, then talk about how you modified it to run with C++ IO.

If your compiler is acting screwy and a reinstall doesn't help, my only suggest is you have virus/trojan/backdoor/etc. on your machine and it is randomy hosing things. I have used DevC and been happy with it (though prefer using VC for most all C/C++ development).
__________________

Free code: http://sol-biotech.com/code/.

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Mitakeet

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw
mitakeet is offline   Reply With Quote
Old Jun 4th, 2005, 8:42 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
My own DevC++ installation is in C:\Dev-Cpp. I put the programs in various places. DevC++ generates a makefile from the settings of the IDE. One may, of course, write their own and choose to run it. One needs to have the include and library paths properly specified. This doesn't sound at all like your problem.

"Make" (nmake for windows installations, as I recall) runs a number of things, the compiler the linker, itself. Some change of working directory is required for each of those things, sometimes. I had one instance where I could successfully build the program from the command line, but "make", using the same parameters, screwed up the process at the linker phase. I restored some files, which fixed it. Being satisfied, I did not pursue the details of the failure mechanism. The only obvious thing was that some cwd or some path specification was failing for the linker that worked for the compiler.

I recommend that you examine your makefile and use the CLI to replicate its chores. In a situation such as this, which may have gone beyond the simple and common errors into actual bug territory, there isn't much you can do except to gather all the information you possibly can and try to narrow things down. Sometimes it's simpler to restore or reinstall things. Restoring or reinstalling things which aren't at fault is, of course, to no avail.

If you'd care to attach a copy of the makefile, I'd be happy to take a look.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers

Last edited by DaWei; Jun 4th, 2005 at 8:45 PM.
DaWei is offline   Reply With Quote
Old Jun 4th, 2005, 10:56 PM   #9
Insomniac
Programmer
 
Insomniac's Avatar
 
Join Date: Aug 2004
Location: Cloud #9
Posts: 47
Rep Power: 0 Insomniac is on a distinguished road
Thanks you guys, I appreciate the assistance.

Im currently running the virus scan, but have found nothing so far. The message "press any key to continue" happens with a handful of programs, C or C++. These programs were once working, some without any modifications. While attempting to inspect the programs my system became drastically unstable, showing bug reports! Here, take a look:


Im looking for that Make file, just want to post this. Thanks


EDIT: that was easy.. there's a bunch of files named with Make so I chose the Win file. Wasn't sure how to actually attach it, so hope it's the correct one:

Quote:
# Project: File Editor Example
# Makefile created by Dev-C++ 4.9.2.9

CC = gcc.exe
WINDRES = windres.exe
RES = FileEditor.res
OBJ = Main.o $(RES)
LIBS = -L"C:\DEV-C++\lib"
INCS = -I"C:\DEV-C++\include"
BIN = FileEditor.exe
CFLAGS = $(INCS) -Wall -s -mwindows

.PHONY: clean

all: FileEditor.exe

clean:
rm -f $(OBJ) $(BIN)

FileEditor.exe: $(OBJ)
$(CC) $(OBJ) -o $(BIN) $(RES) $(LIBS) $(CFLAGS)

Main.o: Main.c
$(CC) -c Main.c -o Main.o $(CFLAGS)

FileEditor.res: FileEditor.rc Menu.rc
$(WINDRES) -i FileEditor.rc -I rc -o FileEditor.res -O coff
__________________
From an IBM Thinkpad T43 - 14.1" SXGA+ - ATI 64 MB X300 - Sonoma 760 - 2 GB RAM - 80 GB HD 5400 - IBM ABG II - FC3, Ubuntu & XPee
DevC++, and Macromedia's - Dreamweaver & Flash Pro and a little Adobe Illustrator & Photoshop
Sleep? Sleep is for the weak.:cool:


Last edited by Insomniac; Jun 4th, 2005 at 11:05 PM.
Insomniac is offline   Reply With Quote
Old Jun 4th, 2005, 11:15 PM   #10
mitakeet
Programmer
 
mitakeet's Avatar
 
Join Date: Jun 2005
Location: Maryland, USA
Posts: 59
Rep Power: 4 mitakeet is on a distinguished road
Your description sounds like you need an OS rebuild, no matter what your virus scan says!
__________________

Free code: http://sol-biotech.com/code/.

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Mitakeet

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw
mitakeet is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:06 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC