![]() |
| | #1 |
| Registered User Join Date: Feb 2009
Posts: 3
| C coding help for finding the weather... NOOB can someone send me in the right direction about how id go about doing this, would i have to connect to rss feeds to check the weather? |
| philmagrill is offline | |
| | #2 |
| Registered User Join Date: Dec 2008
Posts: 183
| u have to find the right website then you have to use either winsock or winnet to access it |
| lolguy is offline | |
| | #3 | |
| Technical Lead Join Date: Aug 2007 Location: London, UK
Posts: 723
| Quote:
C on the other hand has none of that. QuantumPete
__________________ "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support "Have you tried turning it off and on again?" - The IT Crowd | |
| QuantumPete is offline | |
| | #4 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Doesn't libcurl do a lot of that. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #5 |
| Registered User Join Date: Feb 2009
Posts: 3
| Yeh C# makes sense but annoyingly I have to write it in C for the module. Libcurl looks interesting, will investigate cheers. philmagrill |
| philmagrill is offline | |
| | #6 |
| Registered User Join Date: Feb 2009
Posts: 3
| Update: so far i have managed to connect to the internet and DL the bbc rss feed to the file, which i can then open up. I have almost managed to get it to edit the registry to change the desktop background. Atm i am try to parse the file to extract the word sunny form the XML line Code: int main(void)
{
char word[128];
char *p, prefix;
int i;
char string[] = "<title>Saturday: sunny, Max Temp: 16°C (61°F), Min Temp: 4°C (39°F)</title>";
prefix = ',';
p = strchr(string, prefix);
if(p == NULL) {
printf("No %c found.\n", prefix);
}
else {
i = p-string;
//printf("Found %c at position: %d\n", prefix, i+1);
strncpy(word, &string[0], i);
word[i] = '\0';
printf("Weather is: [%s]\n", word);
}
return 0;
}
insert [code] eg Weather is: <title>Saturday: sunny [\code] How do i get it to parse the ":" and just leave the word sunny (also i have just manually written in the string, how would i get it to find that line in a big XML file, would i have to parse the whole file? or can i somehow select that line no. or something?) Thank you Phil |
| philmagrill is offline | |
| | #7 |
| Registered User Join Date: Sep 2006
Posts: 2,512
| What about having the strings you want, in a 2D char array: rainy, sunny, cloudy, etc. [0], [1] [2], etc. Then take your feed into a very large char array and in a loop, strstr() through the page (in the very large char array, until they find the position of the first letter of the first target word that they find. That would eliminate the need to parse, anything. |
| Adak is offline | |
| | #8 |
| Registered User Join Date: Dec 2006
Posts: 1,780
| [offtopic] How about point a webcam out the window and get images from that? [/offtopic] |
| cyberfish is offline | |
| | #9 |
| Registered User Join Date: Apr 2009
Posts: 4
| |
| blkhockeypro19 is offline | |
![]() |
| Tags |
| connection, internet, noob, weather |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Coding noob - Hello World? | spadez | C Programming | 6 | 04-10-2009 04:26 PM |
| The chicken and the egg problem... trying to learn coding but having trouble starting | mothergoose729 | Tech Board | 9 | 03-20-2009 05:22 PM |
| Coding Guideline ....!! | imfeelingfortun | Tech Board | 8 | 10-08-2006 07:09 AM |
| Before Coding | cyberCLoWn | C++ Programming | 16 | 12-15-2003 02:26 AM |
| Coding Contest.... | Koshare | A Brief History of Cprogramming.com | 46 | 10-14-2001 04:32 PM |