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...
User Profile
Collapse
-
strcmp Producing NullReferenceException
-
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... -
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]);
Leave a comment:
-
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
-
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)
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); } }
- iknc4miles...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...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;
- iknc4miles...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.
... -
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...Leave a comment:
-
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&); ... ...
Leave a comment:
-
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);
Leave a comment:
-
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:... -
Nevermind. I just used .substr(pos, length) to create a new string over the old one with fewer characters.
- Miles...Leave a comment:
-
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.";
- Miles -
Thanks for the info Banfa.
Never programmed in C if it isn't already obvious...
- MilesLeave a comment:
-
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.
- MilesLeave a comment:
-
-
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....Leave a comment:
-
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...Leave a comment:
No activity results to display
Show More
Leave a comment: