User Profile

Collapse

Profile Sidebar

Collapse
iknc4miles
iknc4miles
Last Activity: Apr 5 '07, 01:11 PM
Joined: Oct 6 '06
Location: Aberdeen, Maryland, USA
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • iknc4miles
    started a topic strcmp Producing NullReferenceException
    in C

    strcmp Producing NullReferenceException

    Hey everyone,

    Below I try to use strcmp to compare svr_type to a constant string array. Occasionally this produces a NullReferenceEx ception. I put in a try catch just so I could get the full error and this is what I got:

    System.NullRefe renceException: Object reference not set to an instance of an object.
    at strcmp(SByte* , SByte* )

    I'm not entirely sure why. getNextWord modifies the input...
    See more | Go to post

  • iknc4miles
    replied to Help with tokenizing
    in C
    My guess is you are confused about the NULL as the first argument?

    As far as I've ever used it, the first use of strtok needs to specify the character array to be tokenized. After that, as long as you are continuing with the same character array you would call strtok(NULL, (delimiter char)) to get the next token in that array. When strtok returns a NULL value, it has reached the end of the string.

    - iknc4miles...
    See more | Go to post

    Leave a comment:


  • iknc4miles
    replied to Help with tokenizing
    in C
    At first sight, isdigit() takes a single character as an integer value. You're trying to feed it a char* instead of a char. Not sure if this would be the cause of your seg-fault, but it's a start. atoi is used correctly.

    If you're going to use isdigit, you have to check one character at a time. You might even need to cast each char as an int (see below).
    Code:
    int k =0;
    while (1)
    {
        isdigit( (int)tokenarray[1][k]);
    ...
    See more | Go to post

    Leave a comment:


  • iknc4miles
    started a topic Passing structs between Windows Forms - VC++
    in C

    Passing structs between Windows Forms - VC++

    Back with another question. How I go about rewriting this code so that I can pass the pointer to my data from one form to another to be modified there. Here is roughly what I'm doing, but the pointer I end up with is pointing to a blank struct.

    Code:
      // code in Form1 defines tempStruct1 and tempStruct2
    // tempStruct2 has variable int count
    Form2 *vForm = new Form2(&tempStruct1, &tempStruct2);
    vForm->S
    ...
    See more | Go to post

  • DONE! Took me all day but this code should work for any control you want to use in Windows Forms Programming in Managed Visual C++. Just replace TextBox with whatever control you want to use and set the control properties as well.

    Code:
    public __gc class textBoxArray : public System::Collections::CollectionBase
    {
    private: System::Windows::Forms::Form *HostForm;
    
    public: System::Windows::Forms::TextBox *AddNewTextBox(void)
    ...
    See more | Go to post

    Leave a comment:


  • Ok, here's a prt that has been giving me lots of problems. Creating the index property similar to their version.

    How would I go about rewriting:
    Code:
     public System.Windows.Forms.Button this [int Index]
    {
    get
    {
    return (System.Windows.Forms.Button) this.List(Index);
    }
    }
    in C++?

    - iknc4miles...
    See more | Go to post

    Leave a comment:


  • Here's a step by step of my process in imitating the procedure found on that site. This should allow someone else to view what mistakes I'm making.

    1. Open a new project under VC++ -->.NET-->>.NET Empty Project, name application ButtonArrayProj ect.


    2. Add class by going to the Project Menu and selecting VC++ -->Generic-->Generic C++ Class
    name = ButtonArray
    base class = System::Collect ions::Collectio nBase...
    See more | Go to post

    Leave a comment:


  • Thanks for the quick reply.

    I guess my biggest issue is converting C# syntax into managed C++. Many things, such as declaring a readonly instance of a form, I don't know how to do in C++. Instead, I just made and instance that points to a form:

    Code:
    private: System::Windows::Forms::Form *HostForm;
    I will go through again and come back with some more details on syntax issues.

    - iknc4miles...
    See more | Go to post

    Leave a comment:


  • Windows Forms - Control Arrays such as textboxes, buttons, and labels

    Hi all,

    How would I go about making an array of controls such as textboxes for Windows Forms Programming using C++ on VC++ .NET 2003? I've tried porting the C# code from this site, but either I'm not a very good programmer or it doesn't work.

    Do I need to create a class for it? I don't need to dynamically alter the number of textboxes, I just need to be able to reference each text box by an index number.
    ...
    See more | Go to post
    Last edited by iknc4miles; Mar 2 '07, 01:55 PM. Reason: hyperlink added

  • iknc4miles
    replied to How to write for a loop?
    in C
    for loops - general form


    for( 'StartingCondit ion'; 'ConditionConst raint'; 'AdvanceConditi on)
    {

    // Do stuff while ConditionConstr aint is not met

    }

    Usually you write them in a form similar to below

    int i;
    for( i = startingvalue; i < maxvalue; i++)
    {
    cout << i << endl;
    }

    This states that I want to print...
    See more | Go to post

    Leave a comment:


  • iknc4miles
    replied to C++ reading data from file into array
    in C
    This is probably not the problem you're having, but your getInput function within the while loop keeps initialize i to 0 so all your values are stored at (array)[0]. You then advance i by one to a value in your year, month, and rain_in_month arrays that is not defined and try to output it.

    Try rewriting the code like this and see if it helps:
    Code:
    getInput(fin, year&, month&, rain_in_month&);
    ...
    ...
    ...
    See more | Go to post

    Leave a comment:


  • iknc4miles
    replied to Creating a time class - Homework
    in C
    What specific problems are you having? Is it with opening your input file?

    If it's no liking inFile.c_str try this code:
    Code:
    char * temp;
    strcpy(temp, inFile.c_str());
    fin.open(temp);
    See more | Go to post
    Last edited by iknc4miles; Oct 19 '06, 03:46 PM. Reason: forgot one line of code

    Leave a comment:


  • iknc4miles
    started a topic OpenGL and C++.NET
    in C

    OpenGL and C++.NET

    Hi all,

    I'm writing a Windows Form .NET Application in C++ and would like to open a second window for OpenGL Display. My code compiles fine and runs with no problems except that the 2nd window never opens.

    I'm using GLUTMaster wrapper class to update the old C pointers to C++ objects. Info can be found here: http://www.stetten.com/george/glutmaster/glutmaster.html

    Here's the related portion of my code:...
    See more | Go to post

  • iknc4miles
    replied to String modification in C++
    in C
    Nevermind. I just used .substr(pos, length) to create a new string over the old one with fewer characters.

    - Miles...
    See more | Go to post

    Leave a comment:


  • iknc4miles
    started a topic String modification in C++
    in C

    String modification in C++

    Hey all,

    If I have a string such as:

    Code:
    #include <string>
    string str;
    str = "Start: The pink dog was funny.";
    how would I go about removing portions of the string? The book I'm using suggests str.remove(pos, length) where pos = initial position and length = length to be removed from pos. However, remove doesn't seem to be a member function.

    - Miles
    See more | Go to post

  • iknc4miles
    replied to array initlisation
    in C
    Thanks for the info Banfa.

    Never programmed in C if it isn't already obvious...

    - Miles
    See more | Go to post

    Leave a comment:


  • iknc4miles
    replied to array initlisation
    in C
    Ok, the way I wrote it before should work for C. A friend of mine reminded me that "const" was not available in C which doesn't matter anyway if you want to change the values at some point.

    Try it out and see, I don't have a C compiler on me.

    - Miles
    See more | Go to post

    Leave a comment:


  • iknc4miles
    replied to copy file in an array
    in C
    Also, I don't see where the array "lines" is declared.
    See more | Go to post

    Leave a comment:


  • iknc4miles
    replied to copy file in an array
    in C
    What error are you getting? Is it an EndofFileExcept ion?

    Not sure if input is a boolean, but if it is, your while loop will keep going after the file has run out of lines and produce an exception....
    See more | Go to post

    Leave a comment:


  • iknc4miles
    replied to help for book on c++
    in C
    hi!

    Since you already know how to program in C, I suggest "Absolute C++" by Walter Savitch (ISBN 0201709279). It's colorful and well designed for people who programmed in other languages. It includes "Pitfall" sections where people who program in JAVA or C might make mistakes switching over to C++. Also, it only uses the C++ header files instead of deprecated ones in its teachings but shows you how to recreate...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...