-
Fuction Headers
I'm new at C++ and I have found the source for a program but when I compile
it, it says:
error C2447: missing function header (old-style formal list?)
the line number is 28 which is the line above 'string font="Default";'. Can somebody tell me what sort of function header will fix this?
heres the source code:
#include <iostream.h>
#include <string>
#include <stdlib.h>
#include <conio.h>
#include <fstream.h>
#include <stdio.h>
void menu()
{
system("cls");
cout << "******************************\n";
cout << "1.) Insert an Image\n";
cout << "2.) Insert an Image Link\n";
cout << "3.) Insert Text\n";
cout << "4.) Insert Text Link\n";
cout << "5.) Change Font\n";
cout << "6.) Change Font Size\n";
cout << "7.) Change Font Color\n";
cout << "8.) Insert Horizontal Line\n";
cout << "9.) Insert a Break\n";
cout << "10.) Exit WebpageMakerv.1.1\n";
cout << "******************************\n";
}
int string, main();
{
string font="Default";
string fontsize="Default";
string fontcolor="Default";
string text;
string hrcolor;
string align;
string address;
string alink;
string vlink;
string link;
string path;
string color;
......
-
int string, main();
The above should read int main()
[EDIT] Without the semicolon and 'string' [EDIT]
-
problem
but now it says:
error C2065: 'string' : undeclared identifier
-
try replacing
#include <string>
with
#include <string.h>
-
umm..
it has 69 errors but If I put it back to how I had it, it only has the one. The top two are:
'string' : undeclared identifier
syntax error : missing ';' before identifier 'font'
-
Can you please post your current code again?
-
use memset() to place default for a string like this:
char person[10];
memset(person, '\0', 10);
heres how it works:
memset(string, "What you want in it", size);
-
Where would I include the memset. And do you want the full code ?
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#include <fstream.h>
#include <stdio.h>
void menu()
{
system("cls");
cout << "******************************\n";
cout << "1.) Insert an Image\n";
cout << "2.) Insert an Image Link\n";
cout << "3.) Insert Text\n";
cout << "4.) Insert Text Link\n";
cout << "5.) Change Font\n";
cout << "6.) Change Font Size\n";
cout << "7.) Change Font Color\n";
cout << "8.) Insert Horizontal Line\n";
cout << "9.) Insert a Break\n";
cout << "10.) Exit WebpageMakerv.1.1\n";
cout << "******************************\n";
}
int main()
{
string font="Default";
string fontsize="Default";
string fontcolor="Default";
string text;
string hrcolor;
string align;
string address;
string alink;
string vlink;
string link;
string path;
string color;
string name;
string title;
string meta;
cout << "~ Welcome to MaKiT Webpage Maker 1.0 ~\n";
cout << "\nPlease enter a filename.html: ";
getline(cin, name);
ofstream kcout(name.c_str());
kcout << "<html>\n<head>\n"
<<"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">";
cout << "Please Enter The Key words That Search Engines Will use to Describe Your page:\n";
getline(cin,meta);
kcout<<"\n<META NAME=\"keywords\" CONTENT=\""<<meta<<"\">\n";
cout <<"\n\nPlease input a Description of you website:\n";
getline(cin, meta);
kcout << "<META NAME=\"description\" CONTENT=\""<<meta<<"\">\n";
cout << "\n\nWhat is your Name: (Who is the author of this page)\n";
getline(cin,meta);
kcout << "<META NAME=\"author\" CONTENT=\""<<meta<<"\">\n";
cout << "Press any key to continue...\n";
system("cls");
kcout << "\n<title>\n";
cout << "What is the title of your WebPage: ";
getline(cin ,title);
kcout << title<<"\n</title>\n</head>\n";
cout << "Press any key to continue...\n";
getch();
system("cls");
cout << "Do you wish to have a picture or color for your background?\n";
cout << "Type p or c here: ";
string background;
getline (cin ,background);
cout << "Press any key to continue...\n";
getch();
system("cls");
if (background=="p")
....
-
Dunno about memset(). It's fine for char arrays. But he's using string data types here, Sekti.
As for the error you keep getting, i find it odd. Even though you have the include for the string header file, it seems to insist on not recognizing the string name...
What compiler are you using?
-
using
im using MS visual c++ 6.0
-
Ok... just a thought here... remove the .h from the string include and put
using namespace std;
after the includes and before void menu()
-
:-(
102 errors now! weird or what?
-
err... yes weird. I'm afraid I may be misdirecting you :(
Are most of these errors the kind of 'string' : undeclared identifier?
-
with the using namespace thing all the errors are like this:
error C2780: 'class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &,co
nst _E)' : expects 3 arguments - 2 provided
without that they are like this:
syntax error : missing ';' before identifier 'font'
but the identifiers are different and there is the error:
'string' : undeclared identifier
at the start.
-