Cgi for website development in C Language

Source: Internet
Author: User

Cgi for website development in C Language
Zookeeper

  1. Install Apach

  2. Configure ApacheRuntime

    In the following process, click next

    Configure CGI and release the configuration: AddHandler cgi-script. cgi

    2. Add Option,

    3. Write CGI Code as follows: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Vcd4kcjxwiggfsawdupq = "left"> # define_CRT_SECURE_NO_WARNINGS // cancel the security check

    # Include

    # Include

    # Include

    Voidmain ()

    {

    // If you want to display it in html, add the following two sentences:

    Printf ("Content-type: text/html \ n ");

    // Use the following method to query the environment variable string

    Printf ("% s

    ", Getenv (" QUERY_STRING "));

    CharszPost [256] = {0 };

    // Obtain input

    Gets (szPost );

    // Obtain input

    Printf ("% s

    ", SzPost );

    // This statement moves the pointer to the equal sign position.

    Char * p = szPost + 8;

    Char * p1 = strchr (szPost ,"&");

    * P1 = '\ 0 ';

    Charcmd [256] = {0 };

    // String ing

    Sprintf (cmd, "% s> 1.txt", p );

    System (cmd );

    FILE * pf = fopen ("1.txt"," r ");

    // Continue if it is not at the end of the file

    While (! Feof (pf ))

    {

    Charch = fgetc (pf );

    If (ch = '\ n ')

    {

    // Line feed

    Printf ("

    ");

    }

    Else

    {

    // Print characters

    Putchar (ch );

    }

    }

    }

    4. CLICK: local Windows Debugger

    Open the file in file resource manager as follows:

    The Debug directory is as follows:

    5.change system.exebeibei to cgi-binin apachand system.exe to system. cgi.

    6. Restart the Apache server and right-click Apach à Open Apache Monitor. The following page is displayed:

    7. Compile the following html

    It should be noted that, if an error still exists in the webpage, this may not be a program issue, but a cache issue. In this case, you should close the webpage and re-open it, this is the case.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.