Thread: How to get the name of the html file?

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    6
    Hey guys, i know this is an old thread and all, but it relates the most to what i'm trying to do. The only question I have is how do you get the actual file name to download? In the example given where it uses "http://www.google.com/" for the source to copy, i'm trying to use it the same way, but the URLDownloadToFile doesn't work unless it is an actual file like "http://www.google.com/index.htm" or something like that.

    How do I get the name of the html file that is loaded when it is not specified in the address?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    If the filename isn't specified, the browser looks for index.html or index.htm.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Thread moved.

    Hey guys, i know this is an old thread and all, but it relates the most to what i'm trying to do.
    This refers to the thread: I need to open a web page from c++

    The only question I have is how do you get the actual file name to download? In the example given where it uses "http://www.google.com/" for the source to copy, i'm trying to use it the same way, but the URLDownloadToFile doesn't work unless it is an actual file like "http://www.google.com/index.htm" or something like that.
    You might want to state what exactly did you try and how does it not work.

    If the filename isn't specified, the browser looks for index.html or index.htm.
    I had the impression that it is the webserver that controls what page to serve as the index page, e.g., based on the DirectoryIndex configuration variable on Apache.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    6
    Code:
    URLDownloadToFile(NULL, &listText, "listTemp.txt", 0, NULL);
    when listText is "http://www.cppreference.com/stdstring/" it works
    when listText is "http://www.cppreference.com/stdstring/index.html" it works
    when listText is "http://www.cppreference.com/stdstring/strstr.html" it works
    when listText is "http://www.google.com/" it does not work

    What i mean by it does not work is that in my program, the URLDownloadToFile fails, and listTemp.txt is not created

    I know about automatically looking for index.html or index.htm, but when index.html is not found, how do you find the name of the html file that is loaded when you type the url in the browser?

    btw, even though the thread i replied to was in the c++ section, i'm actually using c.
    Last edited by ToniShinobi; 03-15-2008 at 02:22 PM.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by laserlight View Post
    I had the impression that it is the webserver that controls what page to serve as the index page, e.g., based on the DirectoryIndex configuration variable on Apache.
    I'm not sure. Maybe you're right. Maybe we're both right.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM