Hallo Leute
ich wollte grade ein selbstgeschriebendes Programm compilieren und bekomme folgende Fehlermeldung:
param.cc:22: error: ‘argv’ has not been declared param.cc:22: warning: second argument of ‘int main(int, char*, int*)’ should be ‘char **’ param.cc:22: warning: third argument of ‘int main(int, char*, int*)’ should probably be ‘char **’ param.cc: In function ‘int main(int, char*, int*)’: param.cc:27: error: ‘argv’ was not declared in this scope
mein Code sieht so aus:
#include<iostream>
#include<cstdlib>
#include<string>
//Systembibliothek
#include<unistd.h>
using namespace std;
class Configuration
{
public:
string text;
unsigned short line;
bool space;
Configuration():line(0),space(false)
{
}
};
int main(int argc, char*, argv[])
{
int opt=0;
Configuration config;
while((opt = getopt(argc, argv, "d:l:n:t:s"))!=1)
{
switch(opt)
{
case 'd': cout<<"argument d gegeben"<<endl;
case 't': cout<<"argument t gegeben"<<endl;
config.text = optarg;
break;
case 's': cout<<"argument s gegeben"<<endl;
config.space = true;
case 'l':
case 'n':
config.line = atoi(optarg);
break;
default: cout<<"Unbekannte Option "<<(char)optopt<<endl;
break;
}
}
cout<<"------------------------"<<endl;
if (config.line)
{
cout<<config.line<<":";
}
cout<<config.text<<endl;
if (config.space)
{
cout<<endl;
}
cout<<"------------------------"<<endl;
return 0;
}Das Programm soll im terminal gestartet werden und je nach Option ( -s -t usw.) eine Zeile oder eine Beschreibung anzeigen.
danke schon mal im voraus
Moderiert von Into the Pit:
Thema in das richtige Forum verschoben, bitte beachte die als Wichtig markierten Themen (Welche Themen gehören hier her und welche nicht?), Danke.