| | |
Time hour/min/sec
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2009
Posts: 4
Reputation:
Solved Threads: 0
hello. this is my first post in here 
im new to programming and im learning C as my first language.
I need help on this problem, i am making a running clock and it prints out in this format:
1:1:11
but i would like to make it look like in this format:
01:01:11
here is my code so far, i am using Turbo C
i really want to google this problem, but i don't know what to search for.

im new to programming and im learning C as my first language.
I need help on this problem, i am making a running clock and it prints out in this format:
1:1:11
but i would like to make it look like in this format:
01:01:11
here is my code so far, i am using Turbo C

i really want to google this problem, but i don't know what to search for.

C Syntax (Toggle Plain Text)
#include <stdio.h> main() { int sec, min, hour; clrscr(); for (hour=0; hour<=24; hour++) { for (min=0; min<=60; min++) { for (sec=0; sec<=60; sec++) { printf("%d:%d:%d", hour, min, sec); delay(100000000); clrscr(); } } } getch();
%d -> %02d C Syntax (Toggle Plain Text)
#include <stdio.h> int main(void) { int h = 1, m = 1, s = 1; printf("%02d:%02d:%02d", h, m, s); return 0; } /* my output 01:01:01 */
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Sep 2009
Posts: 4
Reputation:
Solved Threads: 0
that works! thanks Dave. 
i have a question, what do you call the process of gathering a data from a web page or website, then those gathered data will be used in your program.
for example i want to get the time from a website, then my program will work base on that website's time.
I wanna learn about it but i don't know what its called, so i really can't google it :p is that possible on C?

i have a question, what do you call the process of gathering a data from a web page or website, then those gathered data will be used in your program.
for example i want to get the time from a website, then my program will work base on that website's time.
I wanna learn about it but i don't know what its called, so i really can't google it :p is that possible on C?
•
•
Join Date: Sep 2009
Posts: 4
Reputation:
Solved Threads: 0
im not sure if this is called html scraping. here is i wanna do. i hope that this is possible in C.
im not really asking for the code, but i hope someone can point me to the right direction, what programming language is this best to perform, what topic is this? what process is this called (connecting my program to mozilla).
this program will ask me for a keyword that i wanna search for, let's say "Dogs". then after entering the keyword, it will automatically open a browser, let say the Mozilla Firefox, it will open several tabs, one is google, the other one is yahoo, and any web search. then it will input the keyword "Dogs" on those web search's search text box. then it will press search.
it should work like this way:
1. Enter Keyword to search (dogs)
2. Open Mozilla Browser
3. Open Multiple tabs
4. Go to URLs of Google, Yahoo, WebSearch
5. Input the keyword (dogs) to those websearch's search text box
6. then press the "search button"
7. those Google, yahoo will then search for "dogs" at the same time.
im not really asking for the code, but i hope someone can point me to the right direction, what programming language is this best to perform, what topic is this? what process is this called (connecting my program to mozilla).
this program will ask me for a keyword that i wanna search for, let's say "Dogs". then after entering the keyword, it will automatically open a browser, let say the Mozilla Firefox, it will open several tabs, one is google, the other one is yahoo, and any web search. then it will input the keyword "Dogs" on those web search's search text box. then it will press search.
it should work like this way:
1. Enter Keyword to search (dogs)
2. Open Mozilla Browser
3. Open Multiple tabs
4. Go to URLs of Google, Yahoo, WebSearch
5. Input the keyword (dogs) to those websearch's search text box
6. then press the "search button"
7. those Google, yahoo will then search for "dogs" at the same time.
In Python it would be very simple, the url string for the search being the most complicated part ...
python Syntax (Toggle Plain Text)
# search google with the default web browser (new tab) # tested with Python 3.1.1 import webbrowser search = 'dog' url = "http://www.google.com/search?hl=en&source=hp&q=%s\ &btnG=Google+Search" % search webbrowser.open_new_tab(url)
May 'the Google' be with you!
•
•
Join Date: Jul 2009
Posts: 4
Reputation:
Solved Threads: 0
0
#9 Oct 8th, 2009
•
•
•
•
%d->%02dC Syntax (Toggle Plain Text)
#include <stdio.h> int main(void) { int h = 1, m = 1, s = 1; printf("%02d:%02d:%02d", h, m, s); return 0; } /* my output 01:01:01 */
I didnt quite get where exactly the clock is running. If this program is executed, then I expect the result always to be /* 01:01:01 */, could you also explain how to run the clock? How to acquire the present time is what I would want to know.
•
•
Join Date: Jul 2009
Posts: 4
Reputation:
Solved Threads: 0
0
#10 Oct 8th, 2009
•
•
•
•
In Python it would be very simple, the url string for the search being the most complicated part ...
python Syntax (Toggle Plain Text)
# search google with the default web browser (new tab) # tested with Python 3.1.1 import webbrowser search = 'dog' url = "http://www.google.com/search?hl=en&source=hp&q=%s\ &btnG=Google+Search" % search webbrowser.open_new_tab(url)
![]() |
Similar Threads
- display system time using int 21 ah = 2ch (Assembly)
- Time Calculator (Java)
- simple c++ program (any help would be greatly appreciated) (C++)
- keystroke to simulate filling petrol (Pascal and Delphi)
- Tutorial: Handling Dates and Time in Delphi (Pascal and Delphi)
- Loop through a year (Python)
- some help needed..changing of time format from 12hour format to 24hour format (Perl)
- add one hour to current time (JavaScript / DHTML / AJAX)
- DVD+RW/+R Burning problems Update (Storage)
- need help w/ typedef (C++)
Other Threads in the C Forum
- Previous Thread: myyashweb
- Next Thread: dynamic memory allocation and structure
| Thread Tools | Search this Thread |
Tag cloud for C
#include adobe ansi array arrays asterisks binarysearch calculate centimeter changingto char convert copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic fflush file fork forloop framework getlasterror givemetehcodez grade graphics gtkgcurlcompiling hacking hardware highest histogram inches include incrementoperators input iso kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard multi mysql number opendocumentformat opensource owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv repetition research reversing scanf scripting segmentationfault sequential shape socket socketprograming spoonfeeding standard string strings structures systemcall testing threads turboc unix user variable voidmain() wab windows.h windowsapi






