-
Hi,
This is my first post.I just started in this powerfull language.Here is what I learned,
Code:
//ASCII characterset generator
void main(void)
{
int a,b,i,j;
clrscr();
printf("\nEnter the range to be generated (min:0 max:254)");
abc:
{
printf("\nMin : ");scanf("%d",&i);
printf("\Max : ");scanf("%d",&j);
}
if (i<0 || j >254)
{
printf("Out of Range!");
goto abc;
}
for (a=i;a<=j;a++)
{
b=a;
printf("\nCode %d : %c",b,b);
}
getch();
}
TC++ Compiler v3.0
-
Your code shouldn't write "goto command". it's bad pattern and very very old writen.
-
Fixed it!
[code]/*ASCII characterset generator*/
void main(void)
{
int a,b,i,j;
clrscr();
printf("\nEnter the range to be generated (min:0 max:254)");
do
{
printf("\nMin : ");scanf("%d",&i);
printf("Max : ");scanf("%d",&j);
if
-
If you wanna be a good style programming , you must should't use "goto command".
If your code have " goto command" , it's call " Spaghetti code ". It very hard for read. ^^