I am trying to finish up this program but it wont compile. I am getting some error messages but don't understand them. Can anyone take a look at my program and see if you can find anything wrong with it? THank you so much in advance this is my final and is due tonight....:sad:

#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cctype>
using namespace std;

struct FORM
{
    char choice [30];
    char meaning[45];
};

FORM *getFormData(string);
string param(string, FORM*);

int main()
{
        
         string BasicData(getenv("QUERY_STRING")); 
         cout << "Content-type:text/html\n\n"; 
     
         
    FORM *form_data = getFormData(BasicData);
    
    string gift = param("gift", form_data); 
    string name = param("name", form_data); 
    string gender = param("gender", form_data);
    string good = param("reason", form_data);
    int reason = atoi(good.c_str());
 
    cout << "<html>" << endl;
    cout << "<head>" << endl;
    cout << "<title>Your Christmas Wish List!</title>" << endl;
    cout << "</head>" << endl;
    cout << "<body>" << endl;
    cout << "<font color=\"#FF9933\">" << endl;
    cout << "<body bgcolor=\"#FFFFCC\">" << endl;
    cout << "<center>" << endl;
    cout << "</center>" << endl;    
    
    switch (reason)
    {
    case 1:
    cout << "Dear Santa, <BR>\n";
    cout << endl; 
    cout << "The one thing I want most for Christmas is " << gift << ". <BR>\n";
    cout << "The reason I really deserve " << gift << " is because I have been a very good " << gender << "<BR>\n";
    cout << "most of the year! <BR>\n";
    cout << "Please Santa, bring me " << gift << "and I will be a good" << gender << "forever.\n<P>";
    break;
    
    case 2:
    cout << "Dear Santa, <BR>\n";
    cout << endl; 
    cout << "The one thing I want most for Christmas is " << gift << ". <BR>\n";
    cout << "The reason I really deserve " << gift << " is because I have been a very good " << gender << "<BR>\n";
    cout << "all year long! <BR>\n";
    cout << "Please Santa, bring me " << gift << "and I will be a good" << gender << "forever.\n<P>";
    break;
    
    case 3:
    cout << "Dear Santa, <BR>\n";
    cout << endl; 
    cout << "The one thing I want most for Christmas is " << gift << ". <BR>\n";
    cout << "The reason I really deserve " << gift << " is because I have been a very good " << gender << "<BR>\n";
    cout << "the month of December! <BR>\n";
    cout << "Please Santa, bring me " << gift << "and I promise to be good" << gender << "from now on.\n<P>";
    break;
  
    case 4:
    cout << "Dear Santa, <BR>\n";
    cout << endl; 
    cout << "The one thing I want most for Christmas is " << gift << ". <BR>\n";
    cout << "The reason I really deserve " << gift << " is because I was a very good " << gender << "<BR>\n";
    cout << "yesterday! <BR>\n";
    cout << "Please Santa, bring me " << gift << "and I promise to be good" << gender << "next year.\n<P>";
    break;
  
    }

    cout << "</center></font></body></html>" << endl;
    system("PAUSE");
    return 0;
}

  
   FORM *getFormData(string BasicData)
{
    int num_fields = 0;
    int length = BasicData.length();
    cout << length;
    for (int index = 0; index < length; index++)
    if (BasicData[index] == '=')
       num_fields++;
       
    FORM *form_data;   
    form_data = new FORM[num_fields];
    
    int field_num = 0;
    int field_pos = 0;
    int count = 0;

    for (field_num; field_num <= num_fields; field_num++) 
    {  
          while (isalnum(BasicData[count]) || isspace(BasicData[count]))
             {
             form_data[field_num].choice[field_pos] = BasicData[count];
             field_pos++;
             count++;
             }            
             
             
          if (BasicData[count] == '=')
             {
             form_data[field_num].choice[field_pos] = '\0';
             field_pos = 0;
             count++;
             }
             
          while (isalnum(BasicData[count]))
             {
             form_data[field_num].meaning[field_pos] = BasicData[count];
             field_pos++;
             count++;
             }   
                                          
          if (BasicData[count] == '\0')
             {
             form_data[field_num].meaning[field_pos] = '\0';
             break;
             }
             
          if (BasicData[count] == '&')
             {
             form_data[field_num].meaning[field_pos] = '\0';              
             field_pos = 0;
             count++;
             }
     }     
     return form_data;
}         

string param(string find_info, FORM *form_data)
{
     string gather_info;
     for (int index = 0; index < 6; index++)
         {
         if (form_data[index].choice == find_info)
         {
            gather_info = form_data[index].meaning;                         
            return gather_info;
         }
         }
           
     string null_string = "";
     return null_string;
}

I've got a non-compiling program too, but if you refer to my post, i gave the compiler output to help direct people to the problem.

I was wondering what you compiled it under c or c++?
I thought struct wasn't used in c++??, although you have C++ includes...

Sorry I can't be more assistance, I'm a noob too!

your program compiled without error with my compiler -- VC++ 6.0 on Windows XP. what compiler are you using? If its really old, such as Turbo C++, then the program may not compile because the compiler is just too ancient.

I thought struct wasn't used in c++??,

structs are ok in c++, but they behave like a class except the defulat access is public.

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.