Jump to content
DarkMark

Cara Guna Dev C++

Recommended Posts

aku br stat blaja programming. dulu aku gna turbo c pah2 nmpk ssh lok. Background biru g2 skt mata nengok. aku bralih nga dev c nmpk senang tp byk lok error berbanding nga turbo c ms aku compile.

Ms nk kuar output pun aku ade mslh. Aku tnya lecturer ph2 dia ckp kna wat system(pause) selepas tutup main. aku wat xjadi pun. dia wat jd lok...... tkn nih

Share this post


Link to post
Share on other sites

bagi aku guna micros0f visual studio 6 lagi senang.. tak perlu buat system("pause") tu.. ;)

Share this post


Link to post
Share on other sites


int main ( void )
{
char c;

cout << "Hello" << endl;
cout << "Press any key to continue..." << endl;
cin >> c;
return 0;
}
[/codebox]

Program akan suspended/pause sampai 'cin >>c' tu dapat execute bila user tekan apa apa key.

Edited by xeonn

Share this post


Link to post
Share on other sites

tu untuk masukkan nilai ahh.. bukan press any key, tapi bila masuk nilai dan tekan enter, baru program tamat..

untuk press anykey, cam zeph cakap...

#include <iostream>
using namespace std;

int main ()
{

cout << "Hello" << endl;

system("pause"); //masa nie dia akan kuar press any key

return 0;
}

;)

Edited by ApoNie

Share this post


Link to post
Share on other sites

tu untuk masukkan nilai ahh.. bukan press any key, tapi bila masuk nilai dan tekan enter, baru program tamat..

untuk press anykey, cam zeph cakap...

.

.

system("pause"); //masa nie dia akan kuar press any key

Refer kat sini pasal system("pause') http://cpp.codenewbie.com/articles/cpp/143...USE-Page_1.html.

i've seen several people use system("PAUSE") when they want to delay their programs. i'm not sure who's teaching this method, but it's a bad habit.

by calling system(), you are invoking the default shell. the shell then executes the commandline given to it ("PAUSE", in this case). that is, it runs the 'pause.exe' program. so, now your simple c program is relying on two external programs for a stupid thing like pressing a single key.

Dia punya sample pulak camni

/* eat up characters until a newline or eof */
do
{
c = getchar();
if(c == EOF) break;
} while(c != '\n');[/codebox]

Lagipun system("pause") tu cuma kat Windows jer ada. Aku dok compile system("pause") dalam linux memanjang tak jumpa "pause" tu punya command.

- Ilmu untuk dikongsi -

Share this post


Link to post
Share on other sites

kalu wat system("pause"); kena save ngan *.c kan?

.cpp pun buleh. asalkan header file yang sepatutnya dah dimasukkan. system("pause").

Sebaik baiknya guna format header file yang baru, macam

#include <cstdio> //standard baru
#include <stdio.h> //cara lama[/codebox]

Kalau tengok dalam <stdio.h>, dia panggil <cstdio> jugak. Terpulang.

Share this post


Link to post
Share on other sites

Lagipun system("pause") tu cuma kat Windows jer ada. Aku dok compile system("pause") dalam linux memanjang tak jumpa "pause" tu punya command.

system("<boleh isi ape2 kat sini>");

universal, cume argument die tak universal,

funsi system ni membolehkan kite panggil program lain dari program tu,

Edited by magnitogorsk.2560-c

Share this post


Link to post
Share on other sites

emm.. baru aku tahu.. thanks atas ilmu tu.. ;)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...