#include<iostream>
#include <string>
#include <fstream>
using namespace std;
struct sndex{
char code[4];
int freq;
};
int main(){
sndex sx[15];
strcpy (sx[0].code, "S100"
//sx[0].code[4], '\0';
sx[0].freq = 1;
strcpy (sx[1].code, "S100"
//sx[1].code[4], '\0';
sx[1].freq = 1;
strcpy (sx[2].code , "S120"
// sx[2].code[4], '\0';
sx[2].freq = 1;
strcpy (sx[3].code , "S130"
// sx[3].code[4], '\0';
sx[3].freq = 1;
strcpy (sx[4].code , "S120"
// sx[4].code[4], '\0';
sx[4].freq = 1;
strcpy (sx[5].code , "S130"
// sx[5].code[4], '\0';
sx[5].freq = 1;
strcpy (sx[6].code , "S140"
// sx[6].code[4], '\0';
sx[6].freq = 1;
strcpy ( sx[7].code , "S130"
// sx[7].code[4], '\0';
sx[7].freq = 1;
strcpy (sx[8].code , "S150"
//sx[8].code[4], '\0';
sx[8].freq = 1;
strcpy (sx[9].code , "S140"
// sx[9].code[4], '\0';
sx[9].freq = 1;
strcpy (sx[10].code , "S150"
//sx[8].code[4], '\0';
sx[10].freq = 1;
cout << "CODE FREQ" << endl;
cout << "============================" << endl;
/*
for(int i =0; i<10; i++){
cout << sx.code << " " << sx.freq << endl;
}
*/
int N = 11;
int m=0;
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++) {
//if(sx==sx[j])sx[j]=' ';
if(!strcmp(sx.code,sx[j].code)){
sx[j].freq+=1;
cout << sx[j].code << " " << sx[j].freq<<endl;
}
}
}
return 0;
}
In the above code I wanted to count no of structs.
Someone give me a clue....
Thanks in advance.
Regards,
Swaroop.
#include <string>
#include <fstream>
using namespace std;
struct sndex{
char code[4];
int freq;
};
int main(){
sndex sx[15];
strcpy (sx[0].code, "S100"
//sx[0].code[4], '\0';
sx[0].freq = 1;
strcpy (sx[1].code, "S100"
//sx[1].code[4], '\0';
sx[1].freq = 1;
strcpy (sx[2].code , "S120"
// sx[2].code[4], '\0';
sx[2].freq = 1;
strcpy (sx[3].code , "S130"
// sx[3].code[4], '\0';
sx[3].freq = 1;
strcpy (sx[4].code , "S120"
// sx[4].code[4], '\0';
sx[4].freq = 1;
strcpy (sx[5].code , "S130"
// sx[5].code[4], '\0';
sx[5].freq = 1;
strcpy (sx[6].code , "S140"
// sx[6].code[4], '\0';
sx[6].freq = 1;
strcpy ( sx[7].code , "S130"
// sx[7].code[4], '\0';
sx[7].freq = 1;
strcpy (sx[8].code , "S150"
//sx[8].code[4], '\0';
sx[8].freq = 1;
strcpy (sx[9].code , "S140"
// sx[9].code[4], '\0';
sx[9].freq = 1;
strcpy (sx[10].code , "S150"
//sx[8].code[4], '\0';
sx[10].freq = 1;
cout << "CODE FREQ" << endl;
cout << "============================" << endl;
/*
for(int i =0; i<10; i++){
cout << sx.code << " " << sx.freq << endl;
}
*/
int N = 11;
int m=0;
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++) {
//if(sx==sx[j])sx[j]=' ';
if(!strcmp(sx.code,sx[j].code)){
sx[j].freq+=1;
cout << sx[j].code << " " << sx[j].freq<<endl;
}
}
}
return 0;
}
In the above code I wanted to count no of structs.
Someone give me a clue....
Thanks in advance.
Regards,
Swaroop.