I have some simple questions:

1) How can I restart my program immediately. For example, when the user press F12 it will restart immediately even if the program is not complete.

2) In scanf the problem is: for example:

                          Height       Width
enter the perimeter:    2

3 < the Cursor moves down what I wanted was that the cursor will remain in the width even the user presses enter. In my code I have scanf("%d %d", &height, &width);

3) How is backspace possible in C? Like when I use the if else my code would be

if(height<2)
{
      It would delete the number typed by the user and make it blank so that the user would understand that u cannot enter a number less than 2.
}

Thx in Advance

Recommended Answers

All 7 Replies

1) you need to create another thread that processes all keyboard input events. But that means you can't use such functions as scanf() in the main program. So it boils down to this: "Don't try that without parental supervision." :)

2) Don't use the <Enter> key between numbers, hit the <Space> bar instead. You have no control over how scanf() behaves. If you want different behavior than you need to write your own version of scanf().

3) The '\b' escape character will cause a backspace. So just printf("\b") should do it, but then the cursor is probably on another line so backspace may not work. And there is no portable way to move the cursor up or down.

1) you need to create another thread that processes all keyboard input events. But that means you can't use such functions as scanf() in the main program. So it boils down to this: "Don't try that without parental supervision." :)

2) Don't use the <Enter> key between numbers, hit the <Space> bar instead. You have no control over how scanf() behaves. If you want different behavior than you need to write your own version of scanf().

3) The '\b' escape character will cause a backspace. So just printf("\b") should do it, but then the cursor is probably on another line so backspace may not work. And there is no portable way to move the cursor up or down.

How come? I have a sample program that has number 2 and 3. This was made in Dev C++ and language used is C. Check the atachment.

>>How come?
Huh? What are you questioning? I gave you my opinion -- if you have code that proves otherwise then why did you ask?

>>How come?
Huh? What are you questioning? I gave you my opinion -- if you have code that proves otherwise then why did you ask?

Dude, THINK! if I knew how to do it, I wont be dumb enough to ask the question. This program is made by someone else and I cannot contact him due to communication distance.

If you dont know the answer, simply just say that you dont know and let others answer it. Oh yeah I figgured out number 2 it is done by using pointers.

Any Ideas of number 1 and 3?

commented: Some people might call this rude. I call it ignorance with a touch of stupidity -2

Dude. READ! I already answered your questions.

There are no standard C functions to do what you want. The explicit answers depends on the operating system you are using. If MS-Windows you can use console functions to manipulate the cursor. For *nix you may have to use the curses library.

Dude. READ! I already answered your questions.

Yah, thx for it. I was just informing that number 2 is possible... I will be soon posting my source code. Currently im trying to make number 1 and 3.

Please reread my previous answer -- I added a little more to it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.