Help on project?

Hey, so recently in my school our teacher wanted us to spend the next 2-3 weeks making up a program of our own choice. (We learned Java in class but I wanted to try something different and learn C++.) Anyway I'm a beginner at C++ and I was wondering how exactly do programs connect to websites/the internet because I wanted to make a program that would notify me of any updates/changes on a website or multiple websites (such as a blog, forum, etc) and provide information about it and archive of it. What I'm really having trouble with is I have no idea how a program connects to the internet in the first place. Could anyone show me somewhere that I could learn this?
Start by using an existing library that handles it for you.

libcurl is popular. http://curl.haxx.se/libcurl/

Fetching a web page is as simple as http://curl.haxx.se/libcurl/c/simple.html

As for telling when the page changes, the most obvious and crudest way is to use libcurl to fetch the page, and compare it to what you got the last time you fetched it. Once that works, you can make it more sophisticated and tune it to the page.

As for how a program connects to a website; well, in general terms the programme asks the operating system to do. How does the operating system do it? That's a big, big question...
Last edited on
You need to use a separate library to connect to a website and exchange information. A quick Google search yields: http://msdn.microsoft.com/en-us/library/aa385331%28VS.85%29.aspx
However, that will be specific to Windows.

Just asking, why use C++ if you already know Java? Learning new languages is great, but are you sure you want to wrestle with learning C++, learning your lib of choice and getting your program to do exactly what you want properly all within a 3 week time limit?
I really appreciate and thank you guys for the responses. I'm going to try what you guys suggested right now.

And the reason why I chose to learn C++ was because our teacher gave us two options to make a program worth 3-4 weeks of programming to finish or learn C++ and make a less difficult program. I started learning C++ last week and I'm going to try to learn what is necessary for the project by the end of this week. The reason why I'm doing this on C++ was because he stated that it was apparently not difficult enough to do on C++ let alone Java... so I would still have to add on to my initial idea of just a notifier.
I agree with ModShop - you have a choice here given your time constraint of 2-3 weeks

1. learn a little bit of beginning C++
2. try to complete your project in Java

Trying to complete your project in Java in 2-3 weeks could already be challenging, if you don't even know how networking works (even though the Java libs do hide a lot of that from you). Besides networking, you still need to learn File I/O or streaming, if you intend to pull down a copy of the website and its links. Come to think of it, just traversing all the links may be non-trivial.

In fact, this kind of project is probably most easily done in Rebol or Ruby, with Java next, and C++ probably the most challenging.

I don't want to discourage you from learning C++, but realize that there are many, many smart people who have studied and used C++ professionally for years, and still find surprises or learn new things on a weekly basis!

Do learn C++ eventually, but do realize that it will take a lot of time and practice - C++ is much harder than Java (but also more powerful, in the sense that it will let you do what you want to do - but you may have to be more verbose or write more baroque-looking code).
Last edited on
Hi, just to be sure how exactly do I add libcurl to my compilers (microsoft visual c++) library?
Last edited on
This comes in three stages.

1) Actually get the libcurl library. Download it from the website, put the files on your machine somewhere sensible; if they come as compiled binaries, job done. If not, you'll have to compile them yourself. By the time you've done this step, you should have some header files (*.h) and some compiled library files (either *.lib or *.dll or both, if I recall Win32 conventions correctly).

2) In your code, include the headers. These essentially explain to the compiler the libcurl types and at the very least the function prototypes, such that the compiler can check that you're calling functions and using new types correctly.

3) In your IDE, find the setting in which you list the names of the libraries to link against. If you are linking statically, you must link against the *.lib libraries. If you're linking dynamically, you must link against the *.dll libraries. This option is buried somewhere in your IDE's settings.

If you get errors regarding "undefined reference" you are not linking against the library correctly.

This is a little old but the principles are identical. http://curl.haxx.se/libcurl/c/visual_studio.pdf
Last edited on
Topic archived. No new replies allowed.