Let's say I want to right justify the int 'number' 5 spaces to the right. I put something like this:
right?Code:printf("%5d",number);
But what if I want to justify it a variable number of spaces to the right? How would I do that?
Thanks!
Printable View
Let's say I want to right justify the int 'number' 5 spaces to the right. I put something like this:
right?Code:printf("%5d",number);
But what if I want to justify it a variable number of spaces to the right? How would I do that?
Thanks!
It's been awhile, let me see if I still remember:
Set "your_variable_number_of_spaces" to however many spaces you need.Code:printf("%*d",your_variable_number_of_spaces,number);
...I think that's right.
OK Now I am having a really big problem. I haven't been able to test that because the compiler is not working. I have reinstalled MinGW, and it doesn't work. I enter the command and it just gets stuck. I am so frustrated right now because I don't have the smallest idea of what the hell is happening.
It has been happening since I reinstalled XP Pro on my computer, but atleast I get it to work after trying two or three times. Now it is not working at all.
Then, when I try to close the command prompt because obviously nothing is happening, it tells me that the program is not responding and it asks me if I should end it now or cancel.
Does anybody have any idea of what is happening? I tried closing a lot of running processes to see if one of them is the problem, but apparently not.
I hate this computer.
Thanks a lot! I still haven't been able to compile it!!! This computer is taking a vacation.
So you enter the command to compile the program, say
and then it just hangs? The command prompt doesn't reappear? [edit] I mean the "C:\>" thing, not the black window. [/edit]Code:gcc program.c -o program.exe
Or are you using Dev-C++?
hello dwks.
Yes, it just hangs if I use that kind of command. It also hangs if I use make. And it also hangs if I use MSYS, the prompt just does not appear, it is if it was still trying to compile.
If I say "gcc file.c", then it just hangs there in primes.c
If I say "make" with a make file that says inside "gcc file.c", then it just hangs at "gcc file.c"
Then, when I close the command prompt window, it says that it is not responding. If I use Ctrl+C, then gcc aborts and the prompt appears (C:\>), but when I close the command prompt window, it says that it is not responding also. And when I try multiple times to compile (using Ctrl + C when it is not successful) then when I close the command prompt it will tell me the number of times I used Ctrl+C that it is not responding.
Yes, I know, confusing.
But I think I managed it. I thought of the biggest change on my system the last couple of weeks, and so, I uninstalled COMODO firewall. Now gcc is working ok.
[edit]
Oh and P.S.: I tried the printf code, it works. Thanks!