Need assistance C++ compiler and linker error messages -
i've been working on program assignment college , i'm done got strange error,and can't find solution anywhere. 1 function program.so...it throws error on part of code. xor operator seems problem. have tried rename name of "nesto" variable in case same name of function no success. please help! ideas ? suggestions ?
error: no match call ‘(std::string {aka std::basic_string}) (int&)’
void* ukupno(void* naziv){ while(kraj!=1){ sem_wait(&s_suma); for(int v=0;v<uk_buffer;v++) nesto^= buffer(v); sem_post(&s_dohvati); } }
here entire code :
#include <iostream> #include <fstream> #include <cstdlib> #include <string.h> #include <unistd.h> #include <sys/wait.h> #include <algorithm> #include <pthread.h> #include <semaphore.h> #include <signal.h> #include <sys/wait.h> using namespace std; bool zastavica=1,kraj; int uk_buffer,broj=0,nesto=0; string buffer; sem_t s_dohvati; sem_t s_broji_rijeci; sem_t s_suma; void otvori_dat(string naziv){ fstream dat; cout<<"naziv " << naziv << endl; dat.open("naziv",ios::in); } void* dohvati(void* naziv){ fstream dat; dat.open((char*)naziv,ios::in); if(!dat){ cout<<"greska kod otvaranja datoteke !!! " << endl; exit(-1);} kraj = false; while(!kraj){ getline(dat,buffer); uk_buffer = buffer.length(); if(dat.eof()) kraj = true; sem_post(&s_broji_rijeci); sem_post(&s_suma); if(kraj) sem_wait(&s_dohvati),sem_wait(&s_dohvati); } dat.close(); } void broji_txt(){ for(int i=0;i<uk_buffer;i++) if(isalnum(buffer[i])){ broj++; while(isalnum(buffer[++i])); } } void broji_html(){ (int i=1;i<uk_buffer;i++) if (buffer[i-1]=='<'&&buffer[i]!='/') broj++; } void* broji_rijeci(void* naziv){ while(kraj!=1){ sem_wait(&s_broji_rijeci); if(zastavica) broji_txt(); else broji_html(); sem_post(&s_dohvati);//postavljanje } } void* ukupno(void* naziv){ int nesto=0; while(kraj!=1){ sem_wait(&s_suma); for(int v=0;v<uk_buffer;v++) nesto^= buffer(v); sem_post(&s_dohvati); } } void analiza(char* naziv){ pthread_t pt_dohvati, pt_broji_rijeci, pt_suma; sem_init (&s_dohvati,0,0); sem_init (&s_broji_rijeci,0,0); sem_init (&s_suma,0,0); pthread_create (&pt_dohvati,null,dohvati,(void*)naziv); //zadnji parametar je ono što šaljem; pthread_create (&pt_broji_rijeci,null,broji_rijeci,null); pthread_create (&pt_suma, null, ukupno, null); pthread_join(pt_dohvati,null); pthread_join(pt_broji_rijeci,null); pthread_join(pt_suma,null); cout << "datoteka " << naziv << " ima " << broj << "rijeci/tagova, zastitna suma je: " <<(unsigned int)nesto; } int main(int arg0 , char* arg1[]){ char* pom; int br_arg = arg0-1;//po njemu se orijentiramo for(int k=1; k<=br_arg;k++){ pom=strchr(arg1[k],'.'); if(strcmp(pom,".txt") == 0) zastavica=1; else if(strcmp(pom,".html") == 0) zastavica=0; else cout<< "datoteka " << arg1[k] << " nije podrzanog formata " << endl; switch(fork()){ case 0 : analiza(arg1[k]),exit(0); case -1 : cerr<< "pogreska pri stvaranju procesa" << endl; default : continue; } } for(int i=0; < br_arg ;i++) wait (null); return 0; }
the error message telling there no way use function call syntax if you've got isn't function string. instead of buffer(v)
, meant buffer[v]
. type of brackets used matters.
Comments
Post a Comment