954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

compile error

Having trouble getting this to compile. My error message says in line 42 expected ';" before "text" any suggestions?

#include <iomanip>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <ctype.h>
using namespace std;

struct FORM
{
    string name;
    string data;
};

void getFormData(string, FORM []);
//FORM *create_array(int);
//string param(string, FORM *dyn_array);
string param(string, FORM *);

int main()
{
        
         

string qs(getenv("QUERY_STRING")); 
cout << "Content-type:text/html\n\n"; 


//FORM *dyn_array;
FORM dyn_array[10];    
getFormData(qs, dyn_array); 

string firstname = param("firstname", dyn_array);
string lastname = param("lastname", dyn_array);

cout << "Content-type:text/html\n\n";
cout <<  "<html>" << endl;
 cout << "<body>" << endl;

cout << "<form>" << endl;
cout << "First name: " << endl;
cout << "<input type="text" name="firstname"> " << endl;

cout << "Last name: " << endl;
cout << "<input type="text" name="lastname"> " << endl;
cout << "</form> " << endl;

cout << "</body> " << endl;
cout << "</html> " << endl;

system("PAUSE");
    return EXIT_SUCCESS;
}
newbie2c++
Newbie Poster
19 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

>>cout << " " << endl;
That line is ill-formed. count the quotes and you will find that the word text is NOT within quotes.
This is probably what you want

cout << "<input type=" << text << " name=" << firstname << "> " << endl;
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

>>cout << " " << endl; That line is ill-formed. count the quotes and you will find that the word text is NOT within quotes. This is probably what you want

cout << "<input type=" << text << " name=" << firstname << "> " << endl;

I think he rather wants to escape the first quote's since there is no variable text and in HTML wouldn't it make a whole lot of sense to make varaible's on that place differ from time to time. To is differing of the formname's in HTML a bad idea. If you want to send the name with it in the form use hidden fields or something.

cout << "<input type=\"text\" name="firstname"> " << endl;


I think that's what you want

BTW, in HTML I thought it was better to end your input thing's with />, so that would make
If you wanted to set the textfield to the firstname it would be:

Anonymusius
Posting Whiz in Training
238 posts since Aug 2006
Reputation Points: 129
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You