Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Moochie5

@Moochie5
About
Posts
16
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • reading and outputting data from a binary file...
    M Moochie5

    Sorry if I wasn't clear. The program does not write to the file but rather reads in the information then outputs it on the screen for the user to see. It does not write to the binary file.

    C / C++ / MFC ios debugging help

  • reading and outputting data from a binary file...
    M Moochie5

    I am having difficulty reading from a binary file. For some reason, the program is not reading from it properly. My code is short and so I will show all of it #include #include struct Info { //unsigned short ID; int ID; float GPA, FinAid; char state[3]; char gender[2]; char Fname[15]; char Lname[15]; char status[15]; }; void main(void) { fstream people; Info person; char again; people.open("C:\\Student.bin", ios::in | ios::binary); if(!people) { cout << "Error Opening File! Program Aborting!!\n\n"; return; } people.read((char *)&person, sizeof(person)); while (!people.eof()) { cout << "ID: "; cout << person.ID << endl; cout << "GPA: "; cout << person.GPA << endl; cout << "Financial Aid: "; cout << person.FinAid << endl; cout <<"State: "; cout << person.state << endl; cout << "Gender: "; cout << person.gender << endl; cout << "First Name: "; cout << person.Fname << endl; cout << "Last Name: "; cout << person.Lname << endl; cout << "Status: "; cout << person.status << endl; cin.get(again); people.read((char *)&person, sizeof(person)); } people.close(); } When I debug it, it will not gather the correct data and also show weird characters. I get the feeling that it is trying to read the file in text file mode still. Not sure why as I've checked examples through the internet and I have pretty much the same code.

    C / C++ / MFC ios debugging help

  • Getting size of file?
    M Moochie5

    Thanks everyone. GetStatus worked.

    C / C++ / MFC help question

  • Getting size of file?
    M Moochie5

    I am opening and reading from a text file and am trying to figure out the function to get the size of the file. Windows reports the file as being 33KB, and I want my program to be able to report that as well. Appreciate the help.

    C / C++ / MFC help question

  • Using FindFirstFile
    M Moochie5

    I am making a program that copies files with certain file extensions, such as .txt, to other directories that are created by the program. I am having difficulty using FindFirstFile. The problem I am having is selecting the directory and all the files with the .txt extensions. For example, this line of code finds all the txt files in the folder where this program is: hSearch = FindFirstFile(TEXT("*.txt"), &FileData); But, I say I need to get all of the .txt files on my c:\txtfiles directory. What is the correct code to do that? I have tried many things, the one that has worked best is this one. hSearch=FindFirstFile(TEXT("c:\\txtfiles\\*.txt"), &FileData); However with this one if there is more than one txt file in the directory my error will say could not find text files. If I leave just one txt file in the directory it will work. I am just looking for the correct code to copy all txt files from a directory on my c drive. Thanks.

    C / C++ / MFC help question tutorial

  • Installing my program on other computers...
    M Moochie5

    I have finished created a setup for my program using the setup wizard in Visual Studio .NET 2003. The setup works fine on my computer and the program works perfect. However, when I go to install the program on other computers it says I need the .NET Framework Redistribution package installed, which I believe is "dotnetfx" when I looked this up on msdn. The problem is I need to run this program at school and demonstrate it to the class. But I cannot install dotnetfx on the computer it because an administrator must do this, students to not have the right access. Does dotnetfx always need to be installed on a computer that doesn't have the .NET Framework on it? Is there anyway around that? I find it hard to believe that for every program that one creates one needs to install dotnetfx on the computer for it to run. Is there any way around that?

    C# csharp dotnet visual-studio help question

  • How to close other processes?
    M Moochie5

    Just want to clarify something... I know how to be able to open more than one program but I'm not sure how to let the computer keep track of them so it closes them all. When I do change it to open more than one program and I enter 4 to close them it does not close any of them.

    C / C++ / MFC tutorial question

  • How to close other processes?
    M Moochie5

    Again thanks for the help Andrzej, I have pretty much configured the program to work how I want except for one thing. I want to be able to open more than one of the same program. So if I open one Paint program I want to be able to enter 3 again for Paint and have it open another. It only lets me open one of each right now. Is there anyway to work around it? Meaning can I keep the global variables or is that one of the things that is preventing me from opening more than one program? Thanks again.

    C / C++ / MFC tutorial question

  • How to close other processes?
    M Moochie5

    Finally got it! Thanks for all the help

    C / C++ / MFC tutorial question

  • How to close other processes?
    M Moochie5

    Thanks for the help Andrzej I have configured the code as shown below: Including a couple of functions. The program builds with 0 errors and 0 warnings, but for some reason when I enter a choice like (1) for "Freecell", my program quits, the program that I have opened remains open, so I do not have the chance to quit the Freecell program. Not sure why it is not giving me another choice: #include #include #include #include void DisplayMenu(); void process(int option); void main() { DisplayMenu(); return; } void DisplayMenu() { int option; cout << "\n\n\n"; cout << "\n\t*********************************"; cout << "\n\t* *"; cout << "\n\t* MENU *"; cout << "\n\t* *"; cout << "\n\t* 1. FreeCell *"; cout << "\n\t* 2. MineSweeper *"; cout << "\n\t* 3. Paint *"; cout << "\n\t* 4. Quit *"; cout << "\n\t* *"; cout << "\n\t*********************************"; cout << "\n\nPlease type your choice " << "and press the return key : "; cin >> option; process(option); return; } void process(int option) { STARTUPINFO si[3]; PROCESS_INFORMATION pi[3]; int i=0; ZeroMemory( &si[0], sizeof(si[0]) ); si[0].cb = sizeof(si[0]); ZeroMemory( &pi[0], sizeof(pi[0]) ); ZeroMemory( &si[1], sizeof(si[1]) ); si[1].cb = sizeof(si[1]); ZeroMemory( &pi[1], sizeof(pi[1]) ); ZeroMemory( &si[2], sizeof(si[2]) ); si[2].cb = sizeof(si[2]); ZeroMemory( &pi[2], sizeof(pi[2]) ); switch (option) { case 1 : if(pi[0].hProcess==NULL)CreateProcess( NULL, "FreeCell.exe", NULL, NULL, FALSE, NULL, NULL, NULL, &si[0], &pi[0]); { ExitProcess(1); } system("cls"); DisplayMenu(); break; case 2 : if(pi[1].hProcess==NULL)CreateProcess( NULL, "winmine.exe", NULL, NULL, FALSE, NULL, NULL, NULL, &si[1], &pi[1]); { ExitProcess(1); } system("cls"); DisplayMenu(); break; case 3 : if(pi[2].hProcess==NULL)CreateProcess( NULL, "MsPaint.exe", // Command line. NULL, NULL, FALSE,

    C / C++ / MFC tutorial question

  • How to close other processes?
    M Moochie5

    Thanks for the reply. I am getting an 3 errors which say "left of .cb must have class/struct/union type". This is the part of the code it is giving those errors: PROCESS_INFORMATION pi[3]; // for each process STARTUPINFO si[3];// init structures ZeroMemory( &si[0], sizeof(si[0]) ); //HERE si.cb = sizeof(si[0]); ZeroMemory( &pi[0], sizeof(pi[0]) ); ZeroMemory( &si[1], sizeof(si[1]) ); //HERE si.cb = sizeof(si[1]); ZeroMemory( &pi[1], sizeof(pi[1]) ); ZeroMemory( &si[2], sizeof(si[2]) ); //HERE si.cb = sizeof(si[2]);

    C / C++ / MFC tutorial question

  • How to close other processes?
    M Moochie5

    Hello, I'm creating a program that displays a menu to the user and gives the user the option to open the following programs: 1. Freecell 2. Minesweeper 3. Paint 4. Quit It does open the programs correctly but when the user enters 4 for quit, I want my program to close all of the programs the user opened. I am not sure how to do that though. I have created a function called ExitProcess and have a call to it when the user enters 4 as their choice. There is no code in that function. Here is most of the code: #include #include #include #include void DisplayMenu(); void CreateProcess(int option); void ExitProcess(void); // Main void main() { DisplayMenu(); return; } void DisplayMenu() { int option; //MENU IS DISPLAYED HERE cout << "\n\nPlease type your choice " << "and press the return key : "; cin >> option; CreateProcess(option); return; } void CreateProcess(int option) { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); switch (option) { case 1 : if( !CreateProcess( NULL, "C://FreeCell.exe",NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi)) { ExitProcess(1); } system("cls"); DisplayMenu(); break; case 2 : if( !CreateProcess( NULL, "winmine.exe",NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi)) { ExitProcess(1); } system("cls"); DisplayMenu(); break; case 3 : if( !CreateProcess( NULL, "MsPaint.exe",NULL,NULL,FALSE, NULL,NULL,NULL,&si,&pi )) { ExitProcess(1); } system("cls"); DisplayMenu(); break; case 4 : WaitForSingleObject( pi.hProcess, INFINITE ); ExitProcess(); CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); exit(100); break; default : cout << "\a\aOption Not Available\n"; system("cls"); DisplayMenu(); } return; } void ExitProcess(void) { }

    C / C++ / MFC tutorial question

  • having trouble timing my program...
    M Moochie5

    The program now outputs duration however, this is something I dont understand. If I run the program normally, meaning without debugging(stepping through it) it says the process takes 0.08000 seconds but if I insert a breakpoint when the file is closing and debug it, it will say the process takes 24.795 secs to do. When I was debugging I put a watch on duration and that was the 24.795 was the correct output. If I run it without the debugging it says 0.08. How or why does debugging change the value of the variable duration?

    C / C++ / MFC

  • having trouble timing my program...
    M Moochie5

    Yes that was it, thanks a lot!

    C / C++ / MFC

  • having trouble timing my program...
    M Moochie5

    I have to do a program that reads from a file and copies that text file to a new one and time how long the process takes to do so. The program copies the files correctly but does not display the time correctly. I will show the entire code since it is pretty small. Right now the duration is equal to finish time - start time / CLOCKS_PER_SEC. The output will say The process took 1202590843 seconds to complete, but when i step through it and put a watch on duration it shows the correct time like 11.567000000 #include #include #include #include #define BUFFER_LEN 200 // # of bytes to read/write // The producer process reads information from the file name // in_test then writes it to the file named out_test. void main(int argc, char *argv[]) { clock_t start,finish; double duration; char buffer[BUFFER_LEN + 1]; // CreateFile parameters DWORD dwShareMode = 0; // share mode LPSECURITY_ATTRIBUTES lpFileSecurityAttributes = NULL; // HANDLE hTemplateFile = NULL; // HANDLE sourceFile; // Source of pipeline DWORD numberOfBytesRead; LPOVERLAPPED lpOverlapped = NULL; // Not used here // WriteFile HANDLE sinkFile; DWORD numberOfBytesWritten; // Open source file start=clock(); //Start Timing the Process sourceFile = CreateFile ( "C://Constitution.txt", GENERIC_READ, dwShareMode, lpFileSecurityAttributes, OPEN_ALWAYS, FILE_ATTRIBUTE_READONLY, hTemplateFile ); if(sourceFile == INVALID_HANDLE_VALUE) { fprintf(stderr, "File Open operation failed\n"); ExitProcess(1); } // Open the sink file sinkFile = CreateFile ( "C://NewVersionConstitution.txt", GENERIC_WRITE, dwShareMode, lpFileSecurityAttributes, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, hTemplateFile ); if(sinkFile == INVALID_HANDLE_VALUE) { fprintf(stderr, "File Open operation failed\n"); ExitProcess(1); } // Main loop to copy the file while ( ReadFile( sourceFile, buffer, BUFFER_LEN, &numberOfBytesRead, lpOverlapped ) && numberOfBytesRead > 0 ) { WriteFile(sinkFile, buffer, BUFFER_LEN, &numberOfBytesWritten, lpOverlapped); } //while (BUFFER_LEN == 200); // Terminating. Close the sink and source files CloseHandle(sourceFile); CloseHandle(sinkFile); finish=clock(); //End timing of process //duration=(double)(finish-start) / 10000; duration=(double)(finish-start) / CLOCKS_PER_SEC; printf("The process took %d ",duration);

    C / C++ / MFC

  • Recieving error: unhandled exception...
    M Moochie5

    Topic cont'd... of type 'System.Data.Odbc.OdbcException' occurred in system.data.dll Additional Information : System error First of all hello, this is my first post, great site here, seems like their a lot of knowledgable people. Anyway I am just beginning to learn C#. I am creating a program for where I work for employees to login with a username and password and after successfully logging in they can clock in and clock out. I am working on the login page first, known as form1 in my project. When the user clicks the "Login" button(known as button1) I would like it to load the next form where the user will be able to clock in and clock out. All the usernames and passwords are on a Access table. They will not be able to create their own but just use the preset ones. I want the program to check if what the user entered in as the username and password match whats on the table and if it does not, then it will display an error. Here is a little snip of my code and I will point out which line the error points to: public void button1_Click(object sender, System.EventArgs e) { OdbcDataReader myReader; string myConnString = "DSN=MS Access Database;DefaultDir=C:\\DOCUMENTS AND SETTINGS\\OWNER\\MY DOCUMENTS;DriverId=25;DBQ=C:\\DOCUMENTS AND SETTINGS\\OWNER\\MY DOCUMENTS\\login.mdb;MaxBufferSize=2048;FIL=MS Access;PageTimeout=5;UID=admin"; //string password; string mySelectQuery = "SELECT Username, Password FROM tblLogin WHERE Username = " + txtUserName.Text; OdbcConnection myConnection = new OdbcConnection(myConnString); OdbcCommand myCommand = new OdbcCommand(mySelectQuery,myConnection); myConnection.Open(); [CODE]myReader = myCommand.ExecuteReader();[/CODE] while(myReader.IsDBNull(0)) { lblErrorUser.Visible=true; } The error points to the myReader = myCommand.ExecuteReader() line. It does open the connection fine but when I click the Login button the error above comes up. If I comment in that line(using //) and the while loop, the program runs fine, well doesnt do what I want it to do but when I click the Login button it opens form2. I believe it has something to do with the myReader variable. I have declared it as OdbcDataReader myReader where I have all my functions declared. I just noticed that their is a blue squiggly under the myReader where its declared. Also, just want to mention that before this 'system error' I was recieving the following error: Exception Details: System.NullReferenceException: Object reference not set to an instance of a

    C# csharp database regex help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups