SuperRembo Posted February 5, 2007 Report Share Posted February 5, 2007 (edited) Varbut varetu seit sarikot mazas sacensibas uz radosiem darbiem pa dev c++ Itka radoss tavs majas sacepums ^^ Varetu seit savus kodus sarakstiit, un tauta noovertetu, cik laba noderiga proga izveidojas pec kompilatora. Labs ir te mans sacepums. //Daumanta Kindzula 2b #include <iostream.h> #include <conio.h> #include <fstream.h> struct Masinas_struktura { int gads; char name[20]; float cena; }; main() { ? ? ?int z; ? ? ?char fails[20]; ? ? ? ? ?Masinas_struktura masina[3]; ? ? ? ? ? ?z=0; ? ? ? ? ? ?while (z<3) ? ? ?{ ? ? ? ? ? ?++z; ? ? ? ? ? ?cout<<"Ievadiet " <<z <<" masinas gadu:"<<endl; ? ? ?cin>>masina[z].gads; ? ? ?cout<<"Ievadiet " <<z <<" masinas marku:"<<endl; ? ? ?cin>>masina[z].name; ? ? ?cout<<"Ievadiet " <<z <<" masinas cenu:"<<endl; ? ? ?cin>>masina[z].cena; ? ? ?cout<<endl; ? ? ? ? ? ? ? ?} z=0; while (z<3) ? ? ?{ ? ? ? ? ?++z; ? ? ?cout<<masina[z].gads<<endl; ? ? ? ? ? ?cout<<masina[z].name<<endl; ? ? ? ? ? ?cout<<masina[z].cena<<endl; ? ? ?cout<<endl; ? ? ? ?} cin >>fails; ofstream f1(fails,ios::out); z=0; while (z<3) { ? ? ?++z; ? ? ? f1 << masina[z].gads<<endl; f1 << masina[z].name<<endl; f1 << masina[z].cena<<endl<<endl; } ? ? ?getch(); ? ? ?} info: 3 masinu dati jaievada- gads,marka,cena. Beigas jaievada faila nosaukums kura vajag saglabat ievadito informaciju - piemeram masina.txt masina.doc DaumantaKindzula2B.exe Edited February 5, 2007 by SuperRembo Link to comment Share on other sites More sharing options...
Tamerlan Posted February 5, 2007 Report Share Posted February 5, 2007 Nu nax es kad redzu C++ drebuļi pār kauliem kā atceros RVT mācības nu nax Link to comment Share on other sites More sharing options...
Dr. Pain Posted February 5, 2007 Report Share Posted February 5, 2007 Varetu seit savus kodus sarakstiit, un tauta noovertetu, cik laba noderiga proga izveidojas pec kompilatora. oi! varen noderiiga proga! juus tik iedomaajaties, ka juusu maajsaimnieciibaa ir 3 mashiinas, un tagad beidzot ir pienaacis tas briidis, kad juus variet visu informaaciju par shiim mashiinaam (gadu, marku un cenu) saglabaat failaa. perfekti!!! p.s. juus variet veelreiz palaist sho progu un saglabaat sho informaaciju citaa failaa. buus lielaaka droshiiba - ja nu vienu failu nejaushi izdzeeshiet!!! Link to comment Share on other sites More sharing options...
DaretodreaM Posted February 5, 2007 Report Share Posted February 5, 2007 nez nez kas taa par kljuudu? Link to comment Share on other sites More sharing options...
hydro Posted February 5, 2007 Report Share Posted February 5, 2007 ideja interesanta labpraat piedaliitos ja pats maaceetu bet nu neko darit. labpraat paveeroshu citu darbus ^^ Link to comment Share on other sites More sharing options...
0xDEAD BEEF Posted February 7, 2007 Report Share Posted February 7, 2007 (edited) Sitais kods ljauj atslegt inputu no kadas hid klaviaturas. nu piemeram - tev programai ir barcode readers un klaviere, bet abi izskatas pec keyboard - tad ar sito zem win xp var atskirot parasto klaviaturas inputu no barcode readera. Beefy nu - cik punkti man pienakas? #include "stdafx.h" #include "Winuser.h" #include "stdio.h" #include "rawinput.h" BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } // This is an example of an exported variable RAWINPUT_API int nRawinput=0; PBYTE key_states[16]; HANDLE key_statesh[16]; int key_statesused = 0; // This is an example of an exported function. RAWINPUT_API int fnRawinput(void) { return 42; } RAWINPUT_API int RAW_RegisterKeyboard(void) { RAWINPUTDEVICE Rid[1]; Rid[0].usUsagePage = 0x01; Rid[0].usUsage = 0x06; Rid[0].dwFlags = 0;//RIDEV_NOLEGACY; // adds HID keyboard and also ignores legacy keyboard messages Rid[0].hwndTarget = NULL;//(HWND)pRawInputDeviceList->hDevice; if (RegisterRawInputDevices(Rid, 1, sizeof (Rid [0])) == FALSE) return 0; return 1; } RAWINPUT_API int RAW_WM_INPUT(UINT msg, WPARAM wParam, LPARAM lParam,char *output) { if (msg == WM_INPUT) { UINT dwSize = 0; GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)); LPBYTE lpb = new BYTE[dwSize]; if (lpb == NULL) { return 0; } if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize ) OutputDebugString (TEXT("GetRawInputData doesn't return correct size !\n")); RAWINPUT* raw = (RAWINPUT*)lpb; int res = 0; if (raw->header.dwType == RIM_TYPEKEYBOARD) { int cks = key_statesused; while(cks && !(key_statesh[--cks] == raw->header.hDevice)); PBYTE vkey_table = key_states[cks] ; if(cks == 0) { if(key_statesused == 15) { while(key_statesused) delete []key_states[key_statesused--]; }; key_statesh[key_statesused] = raw->header.hDevice; vkey_table = key_states[key_statesused] = new BYTE[256]; memset(key_states[key_statesused++],0,sizeof(BYTE[256])); }; vkey_table[raw->data.keyboard.VKey] = 0; if(raw->data.keyboard.Message == WM_KEYDOWN) vkey_table[raw->data.keyboard.VKey] = 0x80; ToAscii(raw->data.keyboard.VKey,raw->data.keyboard.MakeCode,vkey_table,(LPWORD)output,0); if(raw->data.keyboard.Message == WM_KEYUP) *output = 0; res = (int)raw->header.hDevice; } delete[] lpb; return res; } return 0; } // This is the constructor of a class that has been exported. // see rawinput.h for the class definition CRawinput::CRawinput() { return; } Edited February 7, 2007 by 0xDEAD BEEF Link to comment Share on other sites More sharing options...
macho Posted February 7, 2007 Report Share Posted February 7, 2007 man kaut kā neliekas ka tā ir tava programma. Link to comment Share on other sites More sharing options...
0xDEAD BEEF Posted February 7, 2007 Report Share Posted February 7, 2007 (edited) man kaut kā neliekas ka tā ir tava programma. Tapec, ka tu nerubi c++, tapec ari tev ta neliekas! un tie agliskie siti ir kompilera genereti - nesmu neko kopeji no ineta! a- un noteikti esmu kopejis no msdn exampliem kaut kadus gabalus - tapec ari sis tas ir angliski! tb - protams, ka esmu kopejis no interneta, bet tas neskaitas, jo es kopeju sampli, bet mans kods ir pati fiska ar tam keybord tabulam un to es kodeju, kas ari bija pats sarezgitakais, jo izsaukt kaut kadu funkciju, kas kaut ko dara - tas jau nav sarezgiti, sarezgiti ir apstradat atgrieztos datus! es pat atradu to saitu - http://msdn2.microsoft.com/en-us/library/ms645546.aspx Beefy Edited February 7, 2007 by 0xDEAD BEEF Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now