Thread: Need some help guys.

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    4

    Need some help guys.

    lkjh
    Last edited by elvar88; 11-12-2009 at 03:23 PM.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    sleep(N) is a standard function that causes execution to pause (nicely) for N seconds.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by elvar88 View Post
    Code:
                   for(j=1;j==30;j++)
                   {
                   for(i=1;i==4700;i++);
                   }
    Even if it were possible to create a predictable fixed delay using a for-loop (which it's not), that's not how you use a for loop anyway. The middle part of it is the continuation condition. You're saying that the loop should only continue whenever j is already 30.

    You should state what OS you're using here. Windows has a Sleep function that sleeps for a number of milliseconds rather than seconds (and yes that's a capital S in this case).

    main must return int, never void.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    4
    We cant use sleep function for this project. any other ideas??

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by MK27 View Post
    sleep(N) is a standard function that causes execution to pause (nicely) for N seconds.
    sleep() is not standard.

    Quote Originally Posted by elvar88 View Post
    We cant use sleep function for this project. any other ideas??
    Are you using embedded hardware, or is this just something that runs on a normal PC? In embedded hardware, it's pretty common to just use busy loops for delays. Just take the machine instructions that are executed for every loop iteration, and calculate the total number of CPU cycles that are generated per loop iteration. Then divide that into the clock speed to figure out how many loop iterations you need to sleep for the specified amount of time.
    bit∙hub [bit-huhb] n. A source and destination for information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hey guys, I'm new!
    By MrDoomMaster in forum C++ Programming
    Replies: 15
    Last Post: 10-31-2003, 05:47 PM
  2. How long have you guys been working with C/C++??
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 08-01-2003, 03:41 PM
  3. Tic Tac Toe -- Can you guys rate this please?
    By Estauns in forum Game Programming
    Replies: 2
    Last Post: 09-15-2001, 10:22 AM
  4. hello guys
    By lupi in forum C++ Programming
    Replies: 4
    Last Post: 09-13-2001, 06:42 AM
  5. hello guys
    By lupi in forum C++ Programming
    Replies: 1
    Last Post: 09-09-2001, 01:00 AM