WARNING: I am a botanist, not a programmer. If you are offended by newbie questions, please jump to the next thread.

I'm in the Environmental Horticulture at the University of Florida and I'm trying to build an online, multiple-entry key to help students identify the plant families. I have permission to modify and build on a similar script that was written at Colby College, but the computer people there don't have time (understandably) to help me with basic questions. So I'm hoping that someone here can help me out.

Here is the Colby site: http://www.colby.edu/info.tech/BI211/PlantFamilyID.html
Here is the Colby script: http://www.colby.edu/info.tech/BI211/plant_id.c

Questions:
1) Is this script written in C?
2) Will this run on a Windows web host like this one: http://www.accuwebhosting.com/windows-webhosting.htm
3) If not, how do I find a web host where I can run the script? (I looked at various companies, but none of them mentioned having a C compiler. Is that just a given?)
4) Once I've signed up for web hosting, how do I put the files up?
5) How do I compile the script so it will run?

As I said, these are very basic questions, but I'm new to this. Thanks for any help you can give me!

Recommended Answers

All 8 Replies

1. Yes
2, 3, and 4 -- I don't know
5. With a compiler. For MS-Windows you have several choices, such as Code::Blocks and VC++ 2010. For *nix normally compile with gcc, which is on most *nix computers. C programs have to be compiled for the operating system in which it will run, unlike scripting languages such as HTML.

Take a look at this: http://www.cs.tut.fi/~jkorpela/forms/cgic.html Common Gateway Interface is the name for this sort of thing (Colby even calls it that on the websiste). That link goes into some of the technical aspects of it, but it seems if you can find hosting that will run CGI scripts then you should be okay. I don't know if it's correct, but it looks like in that link they compiled the C program to an .exe and simply renamed it .cgi.

Under the software/development tools table further down on that server company page it lists "Full Cgi-Bin Support." You may want to check with them, but that's probably what you're looking for.

Okay, I did a live chat with a tech support person at that company and he said that they didn't offer any server that would run a C program. So now I'm really back to square one.

Everyone on this forum must be running C programs somewhere. How do I join the club and find one of those secret servers?

Again, I'm not an expert, but I think you should have clarified it was a CGI that you wanted to run, not strictly a C program. I think that CGIs had their heyday in the 90s, but have given way to Javascript on the client side interacting with PHP on the server side. This may be a question more for the web development folks. If you think that's the case, hit the "Flag Bad Post" under your name and ask for the thread to be moved to another forum of your choosing.

Okay, I think I'm close to solving the compiler/CGI side of things, but maybe someone here could help me out with a problem in the C source code.

When I try to compile the script, I get an error message saying "839: warning: function returns address of local variable." Someone on another site said the problem was that "the subroutine num2Pstring() returns a pointer to a dynamically allocated stack variable." Unfortunately, that doesn't mean anything to me.

Can anyone advise me on how I should solve this?

You will have to post the code for that function, but the error message means you can not do something like this

char* foo()
{
   char data[25] = "Hello World";
   return data; // error because data is a local variable
}

This is the function with the warning, to my understanding

char *num2Pstring( number )
	int 	number;
{
	int place = 0;
	int hundreds, tens, units;
	char string[5];

	string [ place++ ] = 'P';
	hundreds = number / 100;
	number = number - ( hundreds * 100 );
	tens = number / 10;
	number = number - ( tens * 10 );
	units = number;

	if ( hundreds != 0 )
		string[ place++ ] = hundreds + 48;
	if ( ! ( ( hundreds == 0 ) && ( tens == 0 ) ) )
		string[ place++ ] = tens + 48;
	string[ place++ ] = units + 48;  
	string [ place ] = 0; 
	return( string );
}

At line 6 you should declare string as a char* and allocate memory the array using malloc(/*bytes to allocate*/) to remove the warning message

Thanks for all the responses! After hearing from several people (on this forum and others) I've decided to bail out of the whole C/CGI approach. It looks like I should use javascript, perl, or python, so I'll post a new thread in one of those forums.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.