What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » C help! Please

Pages: (2): « First « 1 [ 2 ] Last »
C help! Please
Author: Message:
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
RE: C help! Please
The problem is some compilers are different. At the end on the main function try adding this. For me the window opens and closes, so I think the basic solution would be adding this:

cin.get();

Edit: Using <windows> would be useless and just add to the filesize as the program is using nothing from the Windows API :P

This post was edited on 09-08-2006 at 02:57 PM by absorbation.
09-08-2006 02:54 PM
Profile PM Find Quote Report
Adeptus
Senior Member
****


Posts: 732
Reputation: 40
Joined: Oct 2005
RE: C help! Please
quote:
Originally posted by .Roy
And when i used turbo c ++ there was a command called gotoxy() where moves your pointer to the following coordinates, like gotoxy(5,30). and its not working, maybe i should just use turbo c
If you are going to want to do things like that (which may not seem much, but believe it or not, are not part of the "standard" library you can always count on), then it may be best to settle on one compiler.

There are three parts to what you are learning: the C language syntax; the standard library, which is very minimal; interacting with the OS and hardware.   The language and the standard library will be the same across different compilers.  Support for interacting with the system beyond what is provided by the standard library will vary -- not just between operating systems, but even between different compilers.  This is what you have been encountering.

You may find this tutorial useful for your cursor positioning needs.

If you need to :google: anything relevant to Dev-C++, include the keyword "MinGW" in your query, as that is the name of the compiler and libraries behind Dev-C++.
09-08-2006 03:17 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: C help! Please
quote:
Originally posted by absorbation
Using <windows> would be useless and just add to the filesize as the program is using nothing from the Windows API
No it wouldn't, as the linker will just chuck away anything that isn't used.
quote:
Originally posted by Adeptus
declared in windows.h
If you wish to use the Windows Sleep function, yes. However, I believe the standard C library has a sleep() too, in unistd.h (I just Googled it :P).

And, as always, remember that different compilers and systems have different libraries.

This post was edited on 09-08-2006 at 03:42 PM by RaceProUK.
[Image: spartaafk.png]
09-08-2006 03:41 PM
Profile PM Web Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
RE: C help! Please
quote:
Originally posted by RaceProUK
No it wouldn't, as the linker will just chuck away anything that isn't used.

Dev-C++ is having some troubles with me at the moment doing that, Visual Stuido didn't, looks like I need to check my configuration or find the cause. Thanks :)

It is pretty bad, a simple Hello World program seems to turn into 1MB in size, I need to fix it ASAP, it has only recently happened :(
09-08-2006 03:44 PM
Profile PM Find Quote Report
Adeptus
Senior Member
****


Posts: 732
Reputation: 40
Joined: Oct 2005
RE: C help! Please
quote:
Originally posted by RaceProUK
If you wish to use the Windows Sleep function, yes. However, I believe the standard C library has a sleep() too, in unistd.h.
This would be true where the full POSIX API is implemented.  MinGW libraries, however, do not have it.

I feel that was a wise decision on their part.  While it would have been very easy to #define it to Windows Sleep() call, there are expectations for POSIX sleep() in regard to signal handling, which could not be met -- in other words, it would be broken.
09-08-2006 03:57 PM
Profile E-Mail PM Find Quote Report
.Roy
Veteran Member
*****

Avatar

Posts: 1526
Reputation: 11
20 / Male / –
Joined: Aug 2004
O.P. RE: C help! Please
I think im going to just use the program that our school uses.
Turbo c/c++

since then i wont have any trouble. Thanks a lot guys :)
09-08-2006 04:36 PM
Profile PM Web Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: RE: C help! Please
quote:
Originally posted by absorbation
quote:
Originally posted by RaceProUK
No it wouldn't, as the linker will just chuck away anything that isn't used.


It is pretty bad, a simple Hello World program seems to turn into 1MB in size, I need to fix it ASAP, it has only recently happened :(


Try compiling it in release mode, not debug.
The previous sentence is false. The following sentence is true.
09-08-2006 08:07 PM
Profile PM Find Quote Report
andrewdodd13
Senior Member
****

Avatar
Oh so retro

Posts: 870
Reputation: 16
34 / Male / Flag
Joined: Jan 2005
RE: RE: C help! Please
quote:
Originally posted by .Roy
quote:
Originally posted by Adeptus
#include <stdio.h>
#include <windows.h>
int main(void)
{
 
    printf("lol\n");
    Sleep(2000);
    printf("Why isnt this working?!");
   
}
Thanks LOADS! :)!

Edit: And when i used turbo c ++ there was a command called gotoxy() where moves your pointer to the following coordinates, like gotoxy(5,30).


I believe the command for gotoxy(x,y) using windows.h is SetCursorPosition(int left, int top). I haven't ever used Dev-C++ - my school were nice enough to give me an old copy of VS6 until .NET 2005 express came out - so this command may not work.

Just make sure you do #include <windows.h> first :)

PS. Just checked, I don't think that command works in C. Use the following:

code:
#include <conio.h>
#include <stdio.h>

int main (void)
{
gotoxy(10,10);
printf("Starts on location 10,10.\n");

return 0;
}

[Image: AndrewsStyle.png]
09-08-2006 08:16 PM
Profile E-Mail PM Web Find Quote Report
.Roy
Veteran Member
*****

Avatar

Posts: 1526
Reputation: 11
20 / Male / –
Joined: Aug 2004
O.P. RE: C help! Please
Gah i always thought "C" was a scripting language that is the same with every program :S wtfux...
09-08-2006 09:48 PM
Profile PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: C help! Please
quote:
Originally posted by .Roy
Gah i always thought "C" was a scripting language that is the same with every program :S wtfux...

C is a specification, not a scripting language. Functions are provided by libraries that come with your compiler, which allow you to use functions provided by the operating system you're using.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
09-08-2006 10:02 PM
Profile PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On