Hello Dan,<br><br>Works a treat. Very grateful,<br><br>I will read through the link you sent me.<br><br>All the best,<br><br>Malcolm.<br><br><div class="gmail_quote">On 31 July 2012 22:16, Daniel Ellis <span dir="ltr"><<a href="mailto:mail@danellis.co.uk" target="_blank">mail@danellis.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Malcom, welcome to the group.<br>
<br>
After trying out your example, I noticed the same behavior which I<br>
didn't expect. Then I found:-<br>
<br>
<a href="http://stackoverflow.com/questions/1716296/why-does-printf-not-flush-after-the-call-unless-a-newline-is-in-the-format-strin" target="_blank">http://stackoverflow.com/questions/1716296/why-does-printf-not-flush-after-the-call-unless-a-newline-is-in-the-format-strin</a><br>
<br>
So fflush is what you need here, for example:-<br>
<br>
printf("Hello world!");<br>
fflush(stdout);<br>
<br>
Regards,<br>
Dan Ellis<br>
<div class="HOEnZb"><div class="h5"><br>
On 31 July 2012 21:36, JACKSON MALCOM <<a href="mailto:malcom.jackson@ntlworld.com">malcom.jackson@ntlworld.com</a>> wrote:<br>
><br>
> Hello all,<br>
> I have just joined KLUG, being very keen on learning about Ubuntu and<br>
> Linux.<br>
><br>
> I have run up against a problem whilst working through Ivor Hortons book<br>
> Beginning C, 3rd edition, using Terminal and CodeBlocks 10.04, on 11.04<br>
> 'Natty Narwhal'.<br>
> There have been a couple of problems such as getchar and buffering that I<br>
> have managed to get solved on line, but now on Page 180 I have hit a brick<br>
> wall.<br>
><br>
> There is a sample program called Simple Simon.<br>
><br>
> Simple Simon is a memory game that posts a sequence of numbers on the screen<br>
> for you to memorise. After 1 second the numbers are erased, and you have to<br>
> key in what you remember, and hope that you have remembered correctly.<br>
><br>
> I have not been able to get the program working on terminal or through code<br>
> blocks, despite several days of trying to find out what is wrong.<br>
> A couple of days ago I decided to start from scratch and write my own<br>
> version of the program, building up a bit at a time and perhaps find out why<br>
> the original program won't work for me.<br>
><br>
> The problem I have is with the following piece of code which should give a<br>
> 1 second delay and then erase the previously printed sequence of numbers.<br>
> (This code works OK on XP and Vista):-<br>
><br>
> #include <stdio.h><br>
> #include <stdlib.h><br>
> #include <time.h><br>
><br>
> int main()<br>
> {<br>
> long now = 0;<br>
> printf("Hello world!");<br>
> now = clock();<br>
><br>
> for(;clock() - now<CLOCKS_PER_SEC; ); /*After 1 second delay<br>
> this "*/<br>
> printf("\r");<br>
> /*"code should erase the string "Hello world!" */<br>
> printf(" ");<br>
><br>
> return 0;<br>
> }<br>
><br>
> I have tried all sorts of delay methods, but they all end up not doing what<br>
> I want to do.<br>
> Instead of writing Hello world! on the screen and erasing it after 1 second,<br>
> the screen comes up and after 1 second Hello world! is printed and erased at<br>
> the same instant.<br>
> I put a break in before the delay, and can see Hello world! is indeed<br>
> printed.<br>
><br>
> On XP and Vista this program works correctly.<br>
><br>
> I have checked through the man pages, but don't yet know enough to know if I<br>
> have found an answer or not. Nothing I have tried works, so would be<br>
> mightily obliged if some one will let me know what to do to get this<br>
> working.<br>
> Many thanks,<br>
> Malcolm Jackson.<br>
><br>
> --<br>
> Hello Ubuntu ...... Goodbye Microsoft.<br>
> <a href="mailto:malcom.jackson@ntlworld.com">malcom.jackson@ntlworld.com</a><br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> Kent mailing list<br>
> <a href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a><br>
> <a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a><br>
<br>
_______________________________________________<br>
Kent mailing list<br>
<a href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Hello Ubuntu ...... Goodbye Microsoft.<br><br>