You are not logged in.
Pages: 1
Hello, today i finally decide with which program language i will code.
After few hours i finally get my first ERROR, and i want you to help me find way out ![]()
So at first point, my code have to count from 15 to 0 and after this says " Hell Yeah"
and from point where is no ERRORS it looks like:
#include <iostream>
#include <unistd.h>
#include <cstdlib>
using namespace std;
int main()
{
for (int i=15; i>=0; i--)
{
cout << i <<endl;
}
cout<<"Hell Yeah!";
return 0;
}But when i want add
sleep(1000);
system("clear");Program should count from 15 to 0 and says Hell Yeah, but here i found my FIRST ERROR ![]()
#include <iostream>
#include <unistd.h>
#include <cstdlib>
using namespace std;
int main()
{
for (int i=15; i>=0; i--)
{
sleep(1000);
system("clear");
cout << i <<endl;
}
cout<<"Hell Yeah!";
return 0;
}In my Console it looks like:
https://imgur.com/YfSBX2K
Any ideas why?
I am using Code:Blocks IDE and GNU GCC compiler, as TUTORIAL says.
Last edited by Gugi (2019-05-04 11:10:28)
- I am using Arch BTW
Offline
Read the Code of Conduct and only post thumbnails http://wiki.archlinux.org/index.php/Cod … s_and_code
Fix your title: https://wiki.archlinux.org/index.php/Co … ow_to_post
And posting screenshots of code output is pointless.
Moving to NC
Offline
You tell your program to sleep for 1500 seconds (i.e. 25 minutes) before continuing. Have you waited for 25 minutes to see if it prints something?
Also, I recommend you try to format your code a bit more carefully (at least proper indentation of the code), to make things more readable (and spot mistakes more quickly).
Online
You tell your program to sleep for 1500 seconds (i.e. 25 minutes) before continuing. Have you waited for 25 minutes to see if it prints something?
Also, I recommend you try to format your code a bit more carefully (at least proper indentation of the code), to make things more readable (and spot mistakes more quickly).
thanks, i got this with your help, but still i got one error ![]()
with :
system("clear");it looks like in console:
https://imgur.com/2Kw9tUD
#update
is this even possible in linux?
Last edited by Gugi (2019-05-04 09:39:08)
- I am using Arch BTW
Offline
That would imply that the shell can't find `clear`, which seems rather odd. Does it work if you run the command from your shell directly?
Then again, as a more general C/C++ programming advice, using the system() call is not very clean anyway.
If your tutorial is telling you to use system() (and tells you to use an IDE for learning to code right away), I would advise using a different tutorial (but then again, that's a personal opinion).
Also, as already mentioned above, please don't paste text output as images.
Online
That would imply that the shell can't find `clear`, which seems rather odd. Does it work if you run the command from your shell directly?
Then again, as a more general C/C++ programming advice, using the system() call is not very clean anyway.
If your tutorial is telling you to use system() (and tells you to use an IDE for learning to code right away), I would advise using a different tutorial (but then again, that's a personal opinion).Also, as already mentioned above, please don't paste text output as images.
Ok, i will not upload text output as images.
Yes, in my shell 'clear' works, so i dont have any idea why it wont works in code
Did you recommend any tutorials with #EasierWay ?
- I am using Arch BTW
Offline
Fix your title: https://wiki.archlinux.org/index.php/Co … ow_to_post
You will not be asked again.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
jasonwryan wrote:Fix your title: https://wiki.archlinux.org/index.php/Co … ow_to_post
You will not be asked again.
Its done,
Problem Solved
- I am using Arch BTW
Offline
Pages: 1