473,889 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TIP: Using a delay in C

Using a delay in C, using Linux. gcc-3.3
This program do a boy in a bike runing in the screen. :D
Its cool to see about games and delay in C.

#include<stdio. h>
int branco(int j){
int k;
for (k=0;k<j;k++)
{
printf(" ");
}

}
int main(){
int i;
for(i=0;i<20;i+ +)
{
//limpa a tela
printf("\033[H\033[2J");
usleep(50000);
branco(i);
printf(" __@\n");
branco(i);
printf(" _`\\<,_\n");
branco(i);
printf(" (*)/ (*)\n");

}
}
Nov 14 '05
17 31941
First, thanks for the atention.
Sorry for my faults in the program, I learned C the day before.
And sorry for some words in portuguese, my live in Brazil, I forget translate in the source.
So, I think is important the portability of the source. I would know where I can learn about the C that I can write to all plataforms, if this is possible.
What C is this C that we are talking about?

I compiled the remaked program, thanks Peter Nilsson, but as Robert Tisdale, I dont liked the graphics. Maybe there is another way to do this program portable and cool. :)
Thanks.

Nov 14 '05 #11
First, thanks for the atention.
Sorry for my faults in the program, I learned C the day before.
And sorry for some words in portuguese, my live in Brazil, I forget translate in the source.
So, I think is important the portability of the source. I would know where I can learn about the C that I can write to all plataforms, if this is possible.
What C is this C that we are talking about?

I compiled the remaked program, thanks Peter Nilsson, but as Robert Tisdale, I dont liked the graphics. Maybe there is another way to do this program portable and cool. :)
Thanks.

Nov 14 '05 #12
First, thanks for the atention.
Sorry for my faults in the program, I learned C the day before.
And sorry for some words in portuguese, my live in Brazil, I forget translate in the source.
So, I think is important the portability of the source. I would know where I can learn about the C that I can write to all plataforms, if this is possible.
What C is this C that we are talking about?

I compiled the remaked program, thanks Peter Nilsson, but as Robert Tisdale, I dont liked the graphics. Maybe there is another way to do this program portable and cool. :)
Thanks.

Nov 14 '05 #13
ehr, sorry for my tripple post! :P
nothing happend, so I pushed f5 sometimes.

Nov 14 '05 #14
"silveira neto" <ot**********@y ahoo.com.br> wrote in message
news:93******** *************** *******@localho st.talkaboutpro gramming.com...
First, thanks for the atention.
Sorry for my faults in the program, I learned C the day before.
IMO nobody can learn C in a day. I've been using C for
about 16 years, but I would not claim to be an 'expert' with it.
I'd only go so far to say I'm more or less 'comfortable' or
'conversant' with it (but not with many of it's 'dark corners'
-- i.e. obscure, less often used features).
And sorry for some words in portuguese, my live in Brazil, I forget translate in the source.

Not a problem.
So, I think is important the portability of the source.
It can be important in many cases, yes.
I would know where I can learn about the C that I can write to all
plataforms, if this is possible.
It is possible. Learn how from good books.
See www.accu.org for peer reviews by the experts.
What C is this C that we are talking about?
The language which is the topic of comp.lang.c is the standard
C language as defined by the international standard ISO/IEC 9899.


I compiled the remaked program, thanks Peter Nilsson, but as Robert

Tisdale, I dont liked the graphics. Maybe there is another way to do this
program portable and cool. :)

Standard C does not support graphics. But graphics can indeed be
done by applying a specialized library to a C program. However,
this will necessarily limit its portability (to those platforms
where the special library has been implemented). One example of
such a 'multi-platform-capable' library is 'wxWindows'.
Nonportable code isn't 'bad' per se, sometimes it's the only way
to do what you need. But I (and many others) still recommend that
as much of a C program as possible be written portably, and that
the platform-specific portions be clearly identified and separated
into their own modules. This will make porting less cumbersome.

HTH,
-Mike
Nov 14 '05 #15
"Peter Nilsson" <ai***@acay.com .au> wrote:
"Mike Wahler" <mk******@mkwah ler.net> wrote in message
news:u%******** **********@news read2.news.pas. earthlink.net.. .
"silveira neto" <ot**********@y ahoo.com.br> wrote in message
int main(){


return 0; /* mandatory for C89, optional for C99 */
}


It's not _mandatory_ in C89 in the strictest sense, merely desirable.


Yes, it is. If you don't explicitly return (or exit()) something from
main(), you may implicitly return a trap value.

Richard
Nov 14 '05 #16
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<40******* *********@news. individual.net> ...
"Peter Nilsson" <ai***@acay.com .au> wrote:
"Mike Wahler" <mk******@mkwah ler.net> wrote in message
news:u%******** **********@news read2.news.pas. earthlink.net.. .
"silveira neto" <ot**********@y ahoo.com.br> wrote in message
> int main(){

return 0; /* mandatory for C89, optional for C99 */
> }


It's not _mandatory_ in C89 in the strictest sense, merely desirable.


Yes, it is. If you don't explicitly return (or exit()) something from
main(), you may implicitly return a trap value.


There aren't any trap representations in C89.

--
Peter
Nov 14 '05 #17
ai***@acay.com. au (Peter Nilsson) wrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<40******* *********@news. individual.net> ...
"Peter Nilsson" <ai***@acay.com .au> wrote:
"Mike Wahler" <mk******@mkwah ler.net> wrote in message
news:u%******** **********@news read2.news.pas. earthlink.net.. .
> "silveira neto" <ot**********@y ahoo.com.br> wrote in message
> > int main(){
>
> return 0; /* mandatory for C89, optional for C99 */
> > }

It's not _mandatory_ in C89 in the strictest sense, merely desirable.


Yes, it is. If you don't explicitly return (or exit()) something from
main(), you may implicitly return a trap value.


There aren't any trap representations in C89.


This is contrary to what several experts, not the least of them, claimed
in c.l.c some time ago when I asked about it.

Richard
Nov 14 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
18854
by: Des L. Davis | last post by:
System: Dell PowerEdge Server with 3 GB RAM, 2.4 GHz Celeron Software: Microsoft SQL Server 2000 Enterprise running on Windows 2003 Server Software: Microsoft SQL Server 2000 Enterprise running on Windows 2000 Server If you run the code below, you'll notice something odd occuring. The MilliSecond value does not change after a 1Millisecond delay. Is this a bug or am I doing something wrong? Any assistance will be greatly appreciated
6
2591
by: Salty Dog | last post by:
Code: <%Response.Buffer = False%> <HTML> <HEAD> <title>Printing</title> </HEAD> <BODY> <center> <% FilePath = "c:\WUTemp\441817810_receiver.txt"
7
2952
by: mfeingold | last post by:
I am working on a system, which among other things includes a server and a ..net control sitting in an html page and connected to the server. I ran into a couple of problems, you guys might have some insight about. 1) It takes 20 sec or so to open a tcp socket from the client to the server. It just sits in the TcpClient.conect waiting for something. When I run the same control from a windows application it connects right away and works...
10
94027
by: AmitTrehan | last post by:
hi friends, I want to know how can we insert delay in vb.net like..... i want to show two strings on same label first one string then break of 5 secs and then second string how can i acheive this? i mean label should show first label.text("before") then it should wait for 5 secs and then it should show label.text("After")
0
1390
by: mookie | last post by:
m looking to create something similar to #region and #endregion using treeviews the problem is that instead of #region, i am using ;fold and ;endfold i am also allowed ot have a fold within a fold and that is where i am stuck. Private Sub rtb_TextChanged(ByVal sender As System.Object, ByVal e As
14
3299
by: Steve Teeples | last post by:
I don't understand why I cannot use a property to modify data within a struct. Can someone tell me why I get the error "Cannot modify the return value of "myData.TheData" because it is not a variable. Here is what breaks. struct Data { public Data(){} private int someData;
8
4244
by: Craig Williamson | last post by:
I'm trying to write a time delay loop in Borland C 3.1 (for legacy code) which has an accuracy of about 0.1ms. This change is due to a hardware change and the software is now running too fast to take proper readings. I have been using delay(1) in the past but it does not have the accuracy that I need for this situation. Does anyone know of a useful C function which can be used to create the time delay? If anyone could help that would...
3
2912
by: TamaThps | last post by:
I have to write a program that lets the user play the game of Craps. As of right now it is incomplete and I have run into some errors. It's my first time using functions instead of the program all being in the int main(). I am using visual studio on windows XP. In my code I've defined a local variable in a function but when I run the program and it gets to that function it says I have an undeclared variable. The code for the program...
7
5024
by: coolnags | last post by:
Hi, As we know IE SELECTdrop down list has limitations on tool tip on individual option items and also horizontal scroll bar. Can any one please tell any other alternative to show the tool tip using javascript or has any one implemented drop down list using div which has all the functionalites of drop down list. Thanks, Nags
0
9969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10794
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9612
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7151
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5830
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3257
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.