Jump to content

Need help REWARD inside

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
w4444x

w4444x

    Newbie

  • Members
  • Pip
  • 2 posts
Hello , I coded one program that worked pretty fine at Linux but when i run it at win it is not working properly. I changed some things that could be problem at win and managed it to run at least but not properly still. Problem is probably somewhere in work with files ( win probably reading new lines or spaces else ??? ) if there is some one who could help me with this write there we will get into contact and if you can help me to fix this iam offering some $ as reward

ty w

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Without seeing some code or a clear description of the expected vs observed behavior, it's almost impossible to help guide you.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
w4444x

w4444x

    Newbie

  • Members
  • Pip
  • 2 posts
int TAddrBook::edit(void){
        std::ifstream addrbook;
        std::ofstream addrbook_b;
        std::string tmp;
        int i=0;
        int tmp1;
        char tmp2;

        addrbook.open ("addr.data", std::ios::in);
        if(!addrbook.is_open()) return 2;

        //vypis obsahu suboru
	system("cls");
        std::cout << "Editacia - Vyberte*kontakt:" << std::endl << std::endl;
        while(!addrbook.eof()){
            i++;
            //addrbook >> tmp;
            std::getline(addrbook,tmp);
            //addrbook >> *firstname >> *surname >> *sex >> *street >> *city >> *PSC >> *mail >> *phone;
            std::getline(addrbook,*firstname);
            std::getline(addrbook,*surname);
            std::getline(addrbook,tmp);
            *sex=tmp[0];
            std::getline(addrbook,*street);
            std::getline(addrbook,*city);
            std::getline(addrbook,tmp);
            *PSC=std::atoi(tmp.c_str());
            std::getline(addrbook,*mail);
            std::getline(addrbook,*phone);
            //addrbook >> tmp >> tmp2;
            std::getline(addrbook,tmp);
            addrbook>>tmp2;

            std::cout << i << ". " << *firstname << " " << *surname << std::endl;
        }
        addrbook.close();

        int count=i;

        //vyber polozky na editaciu
        std::cout << std::endl << "Cislo polozky: ";
        if(std::cin >> tmp1 && tmp1<=count && tmp1>0){

            count=tmp1;

            addrbook.open ("addr.data", std::ios::in);
            if(!addrbook.is_open()) return 2;

            //nastavenie pozicie citaca na zvolenu polozku
            for(i=1;i<tmp1;i++){
                for(int j=1;j<11;j++) addrbook >> tmp;
            }

            //vypis obsahu polozky
            std::cout << "\nKtoru polozku chcete editovat?\n-----\n";
            //addrbook >> tmp;
            std::getline(addrbook,tmp);
            //addrbook >> *firstname >> *surname >> *sex >> *street >> *city >> *PSC >> *mail >> *phone;
            std::getline(addrbook,*firstname);
            std::getline(addrbook,*surname);
            std::getline(addrbook,tmp);
            *sex=tmp[0];
            std::getline(addrbook,*street);
            std::getline(addrbook,*city);
            std::getline(addrbook,tmp);
            *PSC=std::atoi(tmp.c_str());
            std::getline(addrbook,*mail);
            std::getline(addrbook,*phone);
            //addrbook >> tmp;
            std::getline(addrbook,tmp);

            addrbook.close();

            std::cout << "1. " << *firstname << "\n2. " << *surname << "\n3. " << *sex << "\n4. " << *street << "\n5. " << *city << "\n6. " << *PSC << "\n7. " << *mail << "\n8. " << *phone << "\n9. ZIADNU\n\n";

            //zvolenie zaznamu v polozke na editaciu
            std::cout << "Cislo polozky: ";
            if(std::cin >> tmp1 && tmp1<=9 && tmp1>0){

                //ziadna zmena, koniec
                if(tmp1==9) return 0;

                addrbook.open ("addr.data", std::ios::in);
                if(!addrbook.is_open()) return 2;

                //otvorenie pomocneho suboru
                addrbook_b.open ("addrb.data", std::ios::out | std::ios::app);
                if(!addrbook_b.is_open()) return 1;

                //presunutie poloziek bez zmeny
                for(i=1;i<count;i++){
                    for(int j=1;j<11;j++){
                        //addrbook >> tmp;
                        std::getline(addrbook,tmp);
                        addrbook_b << tmp << std::endl;
                    }
                }

                //nastavenie pozicie na polozku, ktora ma byt zmenena
                for(int j=0;j<tmp1;j++){
                    //addrbook >> tmp;
                    std::getline(addrbook,tmp);
                    addrbook_b << tmp << std::endl;
                }

                std::cout << "\nZadajte novu hodnotu: ";
                std::cin >> tmp;

                //uprava hodnoty
                addrbook_b << tmp << std::endl;
                //addrbook >> tmp;
                std::getline(addrbook,tmp);

                //dokoncenie presunu nezmenenych poloziek
                while(!addrbook.eof()){
                    //if(addrbook >> tmp) addrbook_b << tmp << std::endl;
                    if(std::getline(addrbook,tmp)) addrbook_b << tmp << std::endl;
                }

                //zatvorenie suborov
                addrbook_b.close();
                addrbook.close();

                //nahradenie
                 std::remove("addr.data");
                if(std::rename("addrb.data","addr.data")!=0) return 1;
            }
            else{std::cerr << "Chybne zadana hodnota!\n";return 2;}
        }
        else{std::cerr << "Chybne zadana hodnota!\n";return 2;}

        return 0;

there is code of edditing file , and its not working right at windows , but its working good at linux.. need to fix this for win but i dont really know how

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,715 posts
Where exactly does it go wrong? And how?