Results 1 to 8 of 8

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User deathfall's Avatar
    Join Date: Jun:2009
    Location:
    Posts: 405

    C++

    ,
    , . , main . , :

    Code:
    void all(struct poletiStruct pl[])
    {
    	SetConsoleOutputCP(1251);
    	int i = 0;
    	long pos;
    	poletiStruct p;
    	cout << "\n   : \n";
    	fp.open(flights, ios::binary | ios::in);
    	if (!fp)
    	{
    		cout << "\n    !" << endl;
    		exit(1);
    	}
    	fp.seekg(0L, ios::end); 
    	pos = fp.tellg();
    	fp.seekg(0L, ios::beg);
    	for (i = 0; i<pos / (sizeof(poletiStruct)); i++)
    	{
    		fp.read((char*)&p, sizeof(poletiStruct));
    		pl[i] = p;
    		cout << "\n  : " << pl[i].PoletN;
    		cout << "\n    2015 (1-31): " << pl[i].Den;
    		cout << "\n  : " << pl[i].Ime;
    		cout << "\n   : " << pl[i].BrP1;
    		cout << "\n   : " << pl[i].BrP2;
    		cout << "\n     : " << pl[i].CenaB1;
    		cout << "\n     : " << pl[i].CenaB2;
    		cout << "\n=================================\n";
    	}
    	fp.close();
    }
    .
    .

    Code:
    const char flights[] = "poleti.txt";
    const int N = 30;
    struct poletiStruct
    {
    	string Ime;
    	unsigned int PoletN;
    	short unsigned int BrP1;
    	short unsigned int BrP2;
    	float CenaB1;
    	float CenaB2;
    	unsigned int Den;
    };
    int n;
    fstream fp;
    .

  2. #2
    Registered User ined's Avatar
    Join Date: Nov:2006
    Location: Varna
    Posts: 1,078
    , char ime[40];
    ASRock B85 Pro4, Pentium G3240, DD3 8GB/1333MHz, 120GB SSD + 1TB + 640GB HDD
    Gigabyte GV-R657OC-1GI, CM B500, ASUS 24B1S1, LCD SAMSUNG SM931BW, 173

  3. #3
    Registered User deathfall's Avatar
    Join Date: Jun:2009
    Location:
    Posts: 405
    , . getline(cin, pl[i].Ime) cin.getline(pl[i].Ime, 40) .
    Last edited by deathfall; 28th December 2014 at 16:43.

  4. #4
    Registered User ined's Avatar
    Join Date: Nov:2006
    Location: Varna
    Posts: 1,078
    cin.getline(pl[i].Ime, 40) 40 ,

    , :
    cin.getline(pl[i].Ime, 255);
    pl[i].Ime[39]=0;
    Last edited by ined; 28th December 2014 at 16:58.
    ASRock B85 Pro4, Pentium G3240, DD3 8GB/1333MHz, 120GB SSD + 1TB + 640GB HDD
    Gigabyte GV-R657OC-1GI, CM B500, ASUS 24B1S1, LCD SAMSUNG SM931BW, 173

  5. #5
    Registered User deathfall's Avatar
    Join Date: Jun:2009
    Location:
    Posts: 405
    ? . , , .

  6. #6
    Registered User ined's Avatar
    Join Date: Nov:2006
    Location: Varna
    Posts: 1,078
    , fstream - , .
    ASRock B85 Pro4, Pentium G3240, DD3 8GB/1333MHz, 120GB SSD + 1TB + 640GB HDD
    Gigabyte GV-R657OC-1GI, CM B500, ASUS 24B1S1, LCD SAMSUNG SM931BW, 173

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |