char ime[64], kod[64], talant[64];
I had
char *ime,*kod,*talant;
and I also didn't have namespace std. But when I runned the program I could not input "ime". It just printed on the screen the next cout and then I could type in for it. So they told me to change the char declaration to that. It started givign me linker error and a warning when trying to run the program, so I looked it up and found something about namespace std. I tried adding it now, but it gives syntax error. And I think I've used that one before when I copy/pasted Hello World to see if compiler works and it didnd't give me error then.
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <iomanip.h>
using namespace std;
class tal
{
public:
char ime[64], kod[64], talant[64];
int tochki;
public:
void vhod();
void izhod();
}p[300];
int n;
char *swap;
void tal::vhod()
{
cout<<"Trite imena: ";
cin.getline(ime,46);
cout<<"Kod: ";
cin.getline(kod,11);
cout<<"Talant: ";
cin.getline(talant,21);
cout<<"Tochki: ";
cin>>tochki;
cout<<endl;
};
void tal::izhod()
{
char *str1,*str2,*str3,str4,*str5,*str6,*str7,*str8;
int found=1;
for(char *where=ime; *where!=' ';++where)found+=1;
strncpy(str1,ime,found);
str1 += '.\n';
for(*where=ime[found]; *where!=' ';++where)found+=1;
do
{
str2 +=ime[found];
found+=1;
}
while(ime[found]!='\n');
str2 +='\n';
strncpy(str3,kod,3);
str4=kod[3];
switch(str4)
{
case 1:
str5="Sofiq";
break;
case 2:
str5="Plovdiv";
break;
case 3:
str5="Varna";
break;
case 4:
str5="Burgas";
break;
case 5:
str5="Ruse";
break;
case 6:
str5="Blagoevgrad";
break;
};
strncpy(str6,(kod+4),2);
strncpy(str7,(kod+6),2);
strncpy(str8,(kod+8),2);
cout<<str1<<str2<<", "<<str3<<", "<<str5<<", "<<talant<<", "<<tochki<<", "<<str6<<"."<<str7<<"."<<str8<<endl;
}
int main()
{
cout<<"Broi uchastnici: ";
cin>>n;
cout<<endl;
if(n<1 || n>500)
{
cout<<"Greshen broi uchastnici!"<<endl;
return 1;
}
for(int i=0;i<n;i++)
{
p[i].vhod();
}
/*for(i=0;i<n;i++)
{
for (int j=n-1;j>=i;j--)
{
if(strcmp(p[j-1].ime,p[j].ime)>0)
{
swap=p[j-1].ime;
p[j-1].ime=p[j].ime;
p[j].ime=swap;
};
};
} */
for(i=0;i<n;i++)p[i].izhod();
return 0;
}
Edit: Sorry, I think I found the error. My compiler is from 1991 or so. It's version 3.1. o.0
This post has been edited by martinmax3: 23 June 2011 - 06:19 AM

New Topic/Question
Reply



MultiQuote





|