c/c++ and cgi

This is a discussion on c/c++ and cgi within the C++ Programming forums, part of the General Programming Boards category; Hi all I once learnt to programme cgi with ada (for a uni project) and I now have a use ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    100

    c/c++ and cgi

    Hi all

    I once learnt to programme cgi with ada (for a uni project) and I now have a use for cgi but would rather use either c or c++ (preferably c++). Im not sure if it is possible to programme cgi with c or c++, i presume it is. Could somebody please post a link to a good beginners tutorial.

    Thanks in advance

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    It is possible, although you need a CGI-compatible web server.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    Which is almost every major server out there. Out curiosity must you use C/C++? For CGI, I would recommend perl/php.

    As for a link you really should try using google sometimes...

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    32
    Something I wrote when I had curiosity with CGI and C/C++...

    http://www.digitalkeg.com/downloads/...pp/cpp_cgi.zip

    Needs to be compiled on whatever system is supposed to run it. Also, being an executable you may run into issues where the web server you're on won't allow execution. I'd suggest installing Apache or any other web server on your rig and playing with it that way.

    Otherwise if its just a matter of wanting to do web programming, I would suggest like others have mentioned and pick up one of the popular scripting languages such as PHP, ASP, cold fusion, etc. PHP would be your best pick as its what I'd classify as a C syntax language.

    On that note, I don't really recall how complete that code is to be honest. I know I was able to do quite a few things, though the primary reason for its existance was my curiosity of how to use CGI with C/C++.

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    that download

    i got fatal error

    cant open cuz this file doenst exist

    #include "CEMC_Counter.h"
    hooch

  6. #6
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    the biggest thing to remember with using c or c++ for cgi.
    the output of the cgi has to be in a web format.
    ( html )
    you have to send everything needed for a valid webpage from the app.
    the headers included.

    if you don't, then the site visitor will just get a screen ( browser window ) of plain text.

    Code:
    echo <<< <HTML><br>/n;
    echo<<< <title>Title of page / site </title><br>/n;
    if you are coding the site to w3c standards, you would need to make sure you send the dtd and validation header, include a link to the validator..

    everything.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  7. #7
    Registered User
    Join Date
    Oct 2002
    Posts
    32
    Quote Originally Posted by Jaqui
    the biggest thing to remember with using c or c++ for cgi.
    the output of the cgi has to be in a web format.
    ( html )
    you have to send everything needed for a valid webpage from the app.
    the headers included.

    if you don't, then the site visitor will just get a screen ( browser window ) of plain text.

    Code:
    echo <<< <HTML><br>/n;
    echo<<< <title>Title of page / site </title><br>/n;
    if you are coding the site to w3c standards, you would need to make sure you send the dtd and validation header, include a link to the validator..

    everything.
    At the time of writing this, I didn't much care for standards. It was more of learning. Appreciate the note though. I'm sure anyone that wishes to expand their knowledge on this topic would love more of your input here.

    Just remove the CEMC include, its irrelevant. I stripped out what was either uncompleted (ODBC for example) or any additional code which was extra. Figured less is more. Apparently I missed a line or two.
    Last edited by Divx; 08-24-2005 at 02:25 PM.

  8. #8
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    so remove the CEMC and how do you put it on a webpage then? yea that part confuses me lol
    hooch

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CGI program help please
    By Lince in forum C Programming
    Replies: 3
    Last Post: 08-01-2007, 01:31 AM
  2. cgi - c++ returns image
    By terracota in forum C++ Programming
    Replies: 1
    Last Post: 08-04-2004, 09:41 PM
  3. testing a cgi script on my computer
    By Bigbio2002 in forum C Programming
    Replies: 1
    Last Post: 12-14-2003, 06:26 PM
  4. CGI Mailing
    By sean in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 04-14-2003, 09:56 PM
  5. Problem with cgi script - can't rename files
    By bjdea1 in forum C Programming
    Replies: 2
    Last Post: 12-12-2001, 03:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21