why does this crash? Or how would I make it work?

This is a discussion on why does this crash? Or how would I make it work? within the Windows Programming forums, part of the Platform Specific Boards category; Code: void __fastcall TForm1::Button1Click(TObject *Sender) { int i,d,z; char c[5]; for(i=0;i<=7;i++) { z++; c[i]= Edit1->Text[z]; // c... Data being generated ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    21

    why does this crash? Or how would I make it work?

    Code:
    void __fastcall TForm1::Button1Click(TObject *Sender)
    
    {
    int i,d,z;
    char c[5];
    
     for(i=0;i<=7;i++) {
            z++;
            c[i]= Edit1->Text[z]; // c... Data being generated
              }
    
           for(d=0;d<=6;d++) {
    
                Edit2->Text = Edit2->Text+ c[d]+"";
           // WriteFile( HdComm, &c[d], 1, &RealNum, NULL ); //c...is the data
            }
          }
    I would llike to send individual bytes through COM1 to a ÁProcessor , being able to either get the ASCII value orcthe character .

    Any help would be appreciatted.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,853
    As Salem points out, the buffer size.

    and int 'z' is never initialised (and seems redundant).

    The amount of data in the edit buffer is never checked (to ensure is even exists or will fit into the buffer).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. how can i make this work?
    By Darkozuma in forum C++ Programming
    Replies: 2
    Last Post: 08-01-2008, 08:59 PM
  3. Win32 Common Controls in C++, how do i make and use them?
    By C+noob in forum Windows Programming
    Replies: 6
    Last Post: 01-09-2006, 10:53 AM
  4. "Cannot make pipe"
    By crepincdotcom in forum C Programming
    Replies: 5
    Last Post: 08-16-2004, 12:43 PM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21