Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C (http://www.programmingforums.org/forum60.html)
-   -   It's giving me "Press any key to continue" and no other output.. (http://www.programmingforums.org/showthread.php?t=4302)

Insomniac Jun 4th, 2005 3:51 PM

(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. ;)

uman Jun 4th, 2005 6:14 PM

this works fine on my computer.

DaWei Jun 4th, 2005 6:19 PM

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.

Insomniac Jun 4th, 2005 7:26 PM

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:\

Insomniac Jun 4th, 2005 8:18 PM

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...

Ooble Jun 4th, 2005 8:31 PM

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.

mitakeet Jun 4th, 2005 8:32 PM

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).

DaWei Jun 4th, 2005 8:42 PM

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.

Insomniac Jun 4th, 2005 10:56 PM

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:
http://img219.echo.cx/img219/9914/dev14qm.th.jpg

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

mitakeet Jun 4th, 2005 11:15 PM

Your description sounds like you need an OS rebuild, no matter what your virus scan says!


All times are GMT -5. The time now is 12:59 AM.

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