Edited by Sallyqq, 20 August 2009 - 06:47 PM.
Help: TurboC++
Started by Sallyqq, Aug 14 2009 03:47 AM
46 replies to this topic
#1
Posted 14 August 2009 - 03:47 AM
closed````````
|
|
|
#2
Posted 14 August 2009 - 04:27 AM
Post your code. I think I know what you're getting at, but I'd like to see your code to make sure.
sudo rm -rf /
#3
Posted 14 August 2009 - 05:58 PM
for the game part is something like this. The Led blinks follow by the person entering the key then the program telling the person right/wrong. Sorry for the late reply. And thank for the reply.
Note: frequency of sound is not properly set yet.
Note: frequency of sound is not properly set yet.
Game2:
{
putc((char)8,stdprn); //display LEDs 00100000
delay(300);//300ms
putc((char)0,stdprn); //all LEDs off 00000000
delay(300);//300ms
putc((char)4,stdprn); //display LEDs 00000001
delay(300);//300ms
putc((char)0,stdprn); //all LEDs off 00000000
delay(300);//300ms
putc((char)8,stdprn); //display LEDs 00010000
delay(300);//300ms
putc((char)0,stdprn); //all LEDs off 00000000
delay(300);//300ms
printf("\nWhich 3 Leds light up? in sequence:");
scanf("%s",&data);
if (data=='C'||data=='c') [COLOR="Magenta"] <--- first key right, how about telling the person second key and third is right?[/color]
{
printf("\n you are so smart");
{
sound(500);
delay(500);
sound(500);
delay(500);
sound(500);
delay(500);
sound(500);
delay(500);
nosound();
}
}
else if (data!='C' || data!='c'); [COLOR="Magenta"]<-- first key wrong. how about telling the person second and third key wrong?[/COLOR]
{
printf("\nYour memory fail!");
{
sound(500);
delay(500);
sound(500);
delay(500);
sound(500);
delay(500);
sound(500);
delay(500);
nosound();
}
}
printf("\nPress Y to go next level, N to play again");
printf("\nTo quit press Q");
scanf("%s",&data);
Edited by Jaan, 15 August 2009 - 03:27 AM.
Please use code tags when you are posting your codes!
#4
Posted 14 August 2009 - 06:08 PM
Please use code tags. Highlight your code and click on the little pound sign (#).
Probably wrong. If data is a char, then it should be scanf("%c",&data). If data is a character array, then it should be scanf("%*s",data) or scanf("%*c",data) (note no ampersand; replace the asterisk with the length of your buffer.)
I would try this:
scanf("%s",&data);
Probably wrong. If data is a char, then it should be scanf("%c",&data). If data is a character array, then it should be scanf("%*s",data) or scanf("%*c",data) (note no ampersand; replace the asterisk with the length of your buffer.)
I would try this:
#include <string.h>
char data[4];
//get all three characters at once
scanf("%3c", data);
//check all three characters at once, ignoring case
if(strcasecmp(data,"abc") != 0) {
//failed
}
else {
//correct, proceed to next level
}
Edited by dargueta, 15 August 2009 - 09:16 AM.
Typo
sudo rm -rf /
#5
Posted 14 August 2009 - 06:11 PM
hey thank a lot! I will try that out. Super super coding.
#6
Posted 15 August 2009 - 07:34 AM
new help!!
Hello,
Have some other questions,
1) How to make a welcome message in the centre of the screen with it flashing and user can press any key to clear screen and proceed
2) You know the exact frequency of bingo and fail sound?
Example:
Please thank. Thank a lot.
Cheers
Hello,
Have some other questions,
1) How to make a welcome message in the centre of the screen with it flashing and user can press any key to clear screen and proceed
2) You know the exact frequency of bingo and fail sound?
Example:
sound(932+132); delay(500); sound(623+152); delay(500); sound(1223+223); delay(500); nosound();
Please thank. Thank a lot.
Cheers
#7
Posted 15 August 2009 - 07:38 AM
That's highly dependent on the operating system. What library are you using for the sound? (At least tell us what .h file you're including.)
sudo rm -rf /
#8
Posted 15 August 2009 - 07:48 AM
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<dos.h> #include<math.h>
lol. The operating system, you will laugh. It is win 95. I have no idea why my school using that as a assignment.
Thank for replying so fast.
#9
Posted 15 August 2009 - 08:05 AM
dos.h? Really? That's old. Surprised it works, I could never get it to when I tried. You probably have support for graphics.h, another ancient set of functions that don't work on current systems, but did just fine before. I'm not sure if you can use it on Windows systems, I've read conflicting things about it online, but it's worth a shot.
C Language Graphics Library Reference (Part 1)
C Language Graphics Library Reference (Part 2)
C Language Graphics Library Reference (Part 3)
Example Code (Scroll down a little bit further than halfway.)
If that doesn't work, there's some sample code for a more modern way here that you can look at. It's a bit dense, but I can understand most of it so I'll walk you through the code if you have trouble.
C Language Graphics Library Reference (Part 1)
C Language Graphics Library Reference (Part 2)
C Language Graphics Library Reference (Part 3)
Example Code (Scroll down a little bit further than halfway.)
If that doesn't work, there's some sample code for a more modern way here that you can look at. It's a bit dense, but I can understand most of it so I'll walk you through the code if you have trouble.
sudo rm -rf /
#10
Posted 15 August 2009 - 08:05 AM
dos.h? Really? That's old. Surprised it works, I could never get it to when I tried. You probably have support for graphics.h, another ancient set of functions that don't work on current systems, but did just fine before. I'm not sure if you can use it on Windows systems, I've read conflicting things about it online, but it's worth a shot.
C Language Graphics Library Reference (Part 1)
C Language Graphics Library Reference (Part 2)
C Language Graphics Library Reference (Part 3)
Example Code (Scroll down a little bit further than halfway.)
If that doesn't work, there's some sample code for a more modern way here that you can look at. It's a bit dense, but I can understand most of it so I'll walk you through the code if you have trouble.
C Language Graphics Library Reference (Part 1)
C Language Graphics Library Reference (Part 2)
C Language Graphics Library Reference (Part 3)
Example Code (Scroll down a little bit further than halfway.)
If that doesn't work, there's some sample code for a more modern way here that you can look at. It's a bit dense, but I can understand most of it so I'll walk you through the code if you have trouble.
sudo rm -rf /
#11
Posted 15 August 2009 - 09:12 AM
lol. thank for that. I will read it tomorrow. Anyway, does the code above you gave yesterday works for win 95?
#12
Posted 15 August 2009 - 09:16 AM


Sign In
Create Account


Back to top









