header location

Hello,
I would like to convert this into c/c++

<?php
header("Location: " . $_GET['link']);
die();
?>

can someone help me? thanks
apleloisAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
CGI applications receive these values as environment variables. Just use

#include <stdio.h>
int main()
{

   printf("Location:%s\n\n", getenv("QUERY_STRING"));
   exit(0);
}

and it will print

link=http://mysite.com

See also http://hoohoo.ncsa.uiuc.edu/cgi/env.html ("CGI Environment Variables")
0
 
rajeev_devinCommented:
>> header("Location: " . $_GET['link']);
>> die();
What exactly they do ?
0
 
apleloisAuthor Commented:
Lets say the name is (goto.c) and when its compiled is (goto.cgi)
so if im at index.html and I make a links I want to use them this way
<a href="cgi-bin/goto.cgi?link=http://www.google.com">Google</a>
<a href="cgi-bin/goto.cgi?link=http://www.yahoo.com">Yahoo</a>
the 1 links goes directly to google the 2 goes to yahoo
the php script does that
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
apleloisAuthor Commented:
I dont want this, intead of google I want the site
that is in here (goto.cgi?link=http://mysite.com)

#include <stdio.h>
int main()
{

   printf("Location:http://www.google.com\n\n");
   exit(0);
}
0
 
MechanTOurSCommented:
i may suggest you to use a library like libCGI : http://libcgi.sourceforge.net/

about a fast solution to ur problem:

http://www.jmarshall.com/easy/cgi/hello.c.txt

it can get big fast.
0
 
apleloisAuthor Commented:
yes, jkr that is what I was looking for. thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.