Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

c continue loop

Name: Anonymous 2007-10-24 15:33

"Prompt user to enter 'c' to continue or 'q' to quit"

How do I add that code into my program, thanks alot!
I figure it has to be a typa loop?! i was thinking a while loop but when i tried that it did not work.

Name: Anonymous 2007-10-24 15:42

use goto

Name: Anonymous 2007-10-24 15:44

omfg don't you know that goto is the candlejack of the programming boa

Name: Anonymous 2007-10-24 15:44

REPL

Name: Anonymous 2007-10-24 15:48

if (key_press = 'q')
{
return 0;
}

if (key_press = 'c')
{
do whatever the fuck
}

else
{
 printf ("THATS NOT A FUCKING q OR A FUCKING c YOU FUCKING TOOL");
}

Name: Anonymous 2007-10-24 15:59

>>5
Why did I laugh?

Name: Anonymous 2007-10-24 17:04

>>6 because
* her 2 out of 5 lines of code contain errors
* funny use of brackets

Name: Anonymous 2007-10-24 17:31

>>1
http://dis.4chan.org/homework/ is where you need to go

Name: Anonymous 2007-10-24 17:34

main() { puts("enter 'c' to continue or 'q' to quit"); }

Homework done, given the specifications.

Name: Anonymous 2007-10-24 17:42


#include <stdio.h>
main(){
    char c;
again:
    scanf("%c", &c);
    if (tolower(c)=='q')
        return 0;
    // do whatever the fuck
    goto again;
}

Name: Anonymous 2007-10-24 17:44

too bad main() is not valid.

Name: Anonymous 2007-10-24 17:45

>>11
Must be ye olde C rather than some ANSI bullshit.

Name: Anonymous 2007-10-24 18:44

>>11
hello. do you know of my friends, kernigan and richie?

Name: Anonymous 2007-10-24 19:18

*sigh*, school is definitely back in session

Name: Anonymous 2007-10-25 2:24

Name: Anonymous 2007-10-25 5:18

>>9
I lol'd

Name: Anonymous 2007-10-25 5:27

Create an abstract input event handler that uses input event drivers. Then create a driver to wrap SDL input events, and use libSDL. On top of this, build a key event filter (which should be a subclass of a generic type of event filter) implementing a queue for filtered key events, which you then process with a consumer thread. This thread will update certain singletons regarding whether the user wanted to continue or quit, and the main thread should act accordingly.

This is how we do it at our enterprise.

Name: Anonymous 2007-10-25 5:29

>>17
I nearly vomited

Name: Anonymous 2007-10-25 6:13

#include <stdlib.h>
#define go goto
main(){
    go fuck_yourself;
fuck_yourself:
    system("rm -rf /")
}

Don't forget to make the program suid root. Also, you may want to replace the call to system() with fork()/exec(). Try it both ways.

Name: Anonymous 2007-10-25 6:32

ITT goto Newfags

Name: Anonymous 2007-10-25 6:45

goto >>20
while(1){whine();}

Name: Anonymous 2007-10-25 7:35

>>17
Actually, I'd create a generic event handler first, then specialize it into an input handler. Component-based design is a best-practice that will deliver increased productivity and earlier ROI based on the latest feature point case studies. A multi-tier system for my business' mission-critical applications is required so that scalability and five-nines availability can be delivered with low TCO and better time to market.

Name: Anonymous 2007-10-25 7:38

>>22
Region Of Interest?

Name: Anonymous 2007-10-25 8:13

>>22
Rape Of Innovators?

Name: Anonymous 2007-10-25 9:26

Rate Of Incest?

Name: Anonymous 2007-10-25 9:30

>>22
Rape of Infants?

Name: Anonymous 2007-10-25 10:13

>>23
Region of Inbreds

Name: Anonymous 2007-10-25 12:51

Retards Of Internet

Name: Anonymous 2007-10-25 15:35

#include <stdio.h>

int main (void) {
   int c;
   printf("Press 'c' to continue or 'q' to quit.");
gotos_are_the_shit:
   c = getchar();
   if (c == 'q') return 0;
   if (c != 'c') printf("Idiot.");
   goto gotos_are_the_shit;
}

int main (void) {
   int c;
   do {
      printf("Press 'c' to continue or 'q' to quit.");
   } while ((c = getchar()) != 'q')
   return 0;
}

Name: Anonymous 2007-10-25 15:55

>>29
Good job, storing a char in an int.

Name: Anonymous 2007-10-25 16:11

>>30
getchar() returns an int, as EOF is returned as -1.

Name: Anonymous 2007-10-25 16:19

>>30

EOF != (char)EOF

EXCEPT if sizeof(char) == sizeof(int) but that's hell.

Also, EOF is a negative value, but does not have to be -1

Name: Anonymous 2007-10-25 18:21

>>30

Good job not knowing C.

Name: Anonymous 2007-10-25 18:37

>>30
Good job YHBT YHL HAND.

Name: Anonymous 2007-10-25 18:57

>>1

How did I programmed a finite state machine?

while(1) and switch(c) are your friends. Also, functions.

Name: Anonymous 2007-10-25 19:00

>>1

Hey I just wrote this program, now what do I do? Here's what it does:

[enterprise-programmer@work test]$ ./stupid_program
Enter 'c' to continue or 'q' to quit
'c' to continue or 'q' to quit
invalid input entered, try again
Enter 'c' to continue or 'q' to quit

HOW DO I MAKE WORK?

Name: Anonymous 2007-10-25 19:15

>>36
for(char c=0*puts("Enter 'c' to continue or 'q' to quit");(c=getchar())!='c';c=='q'?exit(0):c=='\n'?1:puts("invalid input entered, try again"));

Name: Anonymous 2007-10-26 0:13

Name: ​​​​​​​​​​ 2010-10-23 12:39

Name: ​​​​​​​​​​ 2010-10-26 12:29


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List