wad i need help is that if u press space bar it will stop at the line u r printing and repeat it again and again unless u press space bar again to continue from where u stopped. and my esc dosent seem to work... need help urgently thnx...
int main()
{
int numArray[10]={31,32,33,34,35,36,37,38,39,40}; // ten boxes in int array and is named x,....
int index;
int temp;
char keynum;
printf("\tStart/Stop Number Rotation\n");
printf("\t==========================\n");
printf("\n");
printf("\tHit space bar to start number rotation.\n");
printf("\tTo stop number rotation, hit space bar again.\n");
printf("\tpress ESC to quit at anytime.\n");
printf("\n");
printf("\tHit any key to begin.\n");
system("pause");
while (true)
{
if(kbhit())
{
for(index=0 ; index<10 ; index++)
{
printf("%02d ",numArray[index]); //array start from 21-30
_sleep(100);
}
Please use proper grammar, [code][/code] tags and read the article helios posted as just saying "dosent seem to work..." and posting sourcecode is not a way to get help faster
Firstly wrap your code in [code] and [/code] tags.
Secondly, you notice how we all write "you" as "you" and not "u"? It's two letters, it really doesn't make a difference to how long it takes you to type. It shows a little effort and willingness to learn.
Also if you use proper grammar when writing plaintext it might have the same neatening effect on your code...
Copy and paste the code again, in between [code] and [/code] tags, like this:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define ESC 27
#define SPACE 32
int main()
{
int numArray[10]={31,32,33,34,35,36,37,38,39,40}; // ten boxes in int array and is named x,....
int index;
int temp;
char keynum;
printf("\tStart/Stop Number Rotation\n");
printf("\t==========================\n");
printf("\n");
printf("\tHit space bar to start number rotation.\n");
printf("\tTo stop number rotation, hit space bar again.\n");
printf("\tpress ESC to quit at anytime.\n");
printf("\n");
printf("\tHit any key to begin.\n");
system("pause");
while (true)
{
if(kbhit())
{
for(index=0 ; index<10 ; index++)
{
printf("%02d ",numArray[index]); //array start from 21-30
_sleep(100);
}
printf("\t\n");
for(index=0 ; index<9 ; index++)
{
temp = numArray[index];
numArray[index] = numArray[index+1];
numArray[index+1] = temp;
}
}
elseif(keynum==SPACE)
{
for(index=0 ; index<10 ; index++)
{
printf("%02d ",numArray[index]);
_sleep(100);
}
}
elseif(keynum==ESC)
{
break; //break out of loop
}
}
printf("Try again?");
printf("\n");
system("pause");
return 0;
}
erm what is the code tags for? as i have no learnt it yet.
and im not sure wad you mean by this.
''Secondly, you notice how we all write "you" as "you" and not "u"? It's two letters, it really doesn't make a difference to how long it takes you to type. It shows a little effort and willingness to learn.'' sorry my english sux...