179 Posted Topics

Member Avatar for FilteR

Use the Contains method of the string class to find substrings. [code=csharp] string s = "Hello World!"; if ( s.Contains( "Hello" ) ) { Console.WriteLine( "Found \"Hello\" in the string" ); } [/code]

Member Avatar for Hamrick
0
108
Member Avatar for johnray31

It's not bad to do anything. Even global variables aren't bad. They can make it harder to troubleshoot or reuse your code, but saying they're bad is weird. You have the same issue with static variables. They're not right for a function that has to be re-entrant but it they …

Member Avatar for Hamrick
0
110
Member Avatar for shouvik.d

State means that info persists between calls. If you want to keep a running total of some statistic, that's state, and it's hard to maintain with functions. You have to use a global variable or a parameter. [code=cplusplus] int count1 = 0; void function( int& count2 ) { // do …

Member Avatar for vijayan121
0
310
Member Avatar for shouvik.d

[url=http://code.google.com/p/google-sparsehash/]This[/url] one's good.

Member Avatar for Rashakil Fol
0
153
Member Avatar for jbennet

[QUOTE]I remember hearing that you have to ask cin to throw away the enter or something?[/QUOTE] Yeah something like that. Try adding cin.ignore like this. [code=cplusplus] cin >> choice; cin.ignore( 80, '\n' ); [/code]

Member Avatar for Salem
0
155
Member Avatar for Firestone

Just use the array name when you call your function. [code=cplusplus] getMove( move, space ); [/code]

Member Avatar for narendharg
0
122
Member Avatar for cheongsiwei

[QUOTE]i need a detail explanation how the program work[/QUOTE] Didn't you write it? :confused:

Member Avatar for JRM
0
210
Member Avatar for Hamrick

I'm writing a doubly linked list and a lot of the code ends up being the same with _next and _prev switched. What can I do to keep from writing some code with _next and then the same code again with _prev? Can I do like a template that flips …

Member Avatar for Bench
0
97
Member Avatar for VISHOWNTAR

[QUOTE]That's as close as I can get without giving you the answer on a plate.[/QUOTE] Everybody doesn't think in code, and that example is pretty vague. [QUOTE]Will you please give me little detail hint?[/QUOTE] When you loop over a 2D array, you use two loops, right? One loop on the …

Member Avatar for VISHOWNTAR
0
2K
Member Avatar for Reg74

From the prototype I'd guess this. [code=cplusplus] template<class T> void Stack<T>::Output(T element) { cout<< element; } [/code] I don't understand why you have a parameter. It seems you want to output the whole stack. [code=cplusplus] template<class T> void Stack<T>::Output() { for ( int i = 0; i < pool.size(); ++i …

Member Avatar for Reg74
0
169
Member Avatar for RohitSahni
Member Avatar for mauro21pl

[QUOTE]15 ISO C++ forbids declaration of `privite' with no type[/QUOTE] The error says it all. private is misspelled.

Member Avatar for Bench
0
143
Member Avatar for mohammadalipak

You can't set the size of an array at run time. You have to dynamically create the array from a pointer. [code=cplusplus] typedef struct tagPredefinedStruct{ int iSize; int iCount; } PREDEFINEDSTRUCT; typedef struct APIStruct { int iNumber; PREDEFINEDSTRUCT *PreDefStruct; int iDate; } APISTRUCT; APISTRUCT api; int x; x = GetNumberofStructs(); …

Member Avatar for mohammadalipak
0
287
Member Avatar for boss16thugz

If you want to use variables in more than one method, you should make them member variables instead of local variables.

Member Avatar for boss16thugz
0
298
Member Avatar for mauro21pl

I don't understand. I guess it depends on the data type of the variable that you're storing the bytes in.

Member Avatar for Bench
0
110
Member Avatar for mauro21pl

When you divide by 2 and the remainder is 0, the number's even. [code] if ( x % 2 == 0 ) { // even } else { // odd } [/code]

Member Avatar for Hamrick
0
68
Member Avatar for kapish ketan

Everything gets inherited and the public, protected or private accessibility just says if the derived class can use something or not.

Member Avatar for Hamrick
0
49
Member Avatar for mauro21pl

Is Cstring a class? If it lets you get an individual character and the size, you can do this easy. [code] char MiddleCharacter( Cstring string ) { return string[string.length() / 2]; } [/code] A char array string is the same way but you have to use strlen. [code] char MiddleCharacter( …

Member Avatar for mauro21pl
0
208
Member Avatar for 1qaz2wsx7

[QUOTE]1) How can i get the size of the screen ? (not the forum, the screen borders)[/QUOTE] You can find that stuff in the [url=http://msdn2.microsoft.com/en-us/library/system.windows.forms.systeminformation_members.aspx]SystemInformation[/url] class. [QUOTE]2) How can i resize all the columns in a DataGridView to the length of their values ?[/QUOTE] The only sure way I know …

Member Avatar for TheGathering
0
300
Member Avatar for quintoncoert

System.String.Format lets you do that with the D and X formatters. [code=csharp] string decString = string.Format( "{0:D}", decValue ); string hexString = string.Format( "{0:X}", hexValue ); [/code] You can also just print the formatted values with Write or WriteLine because they use the same formatter strings.

Member Avatar for Hamrick
0
84
Member Avatar for alfredwooden

You can find out where the exe is with command line arguments. [code=cplusplus] #include <iostream> using namespace std; int main( int argc, char *argv[] ) { cout<< argv[0] <<endl; return 0; } [/code] Once you have that string, you can trim off the filename and then have a path for …

Member Avatar for Hamrick
0
91
Member Avatar for Hamrick

Is there a way to pass a function template to another function? I tried this but it doesn't work. [code=cplusplus] template <typename T> void template_function( T arg ) { } void function( template <typename T> void (*func)( T arg ) ) { } [/code] How can I pass a function …

Member Avatar for vijayan121
0
331
Member Avatar for Hamrick

I wrote this trying to understand templates, functors and inheritance. it works but I want to know if there's a better way. Is a base and derived class overkill for a sorting function? How cand I make it better? [code=cplusplus] /* sorting test Class based sorting by Kimberly Hamrick */ …

Member Avatar for thekashyap
0
150
Member Avatar for vladdy19

[QUOTE]how could i change a pointer pointing to Personnel and have it point to Student?[/QUOTE] You can typecast it. [code] s = (Student*)person; [/code]

Member Avatar for ~s.o.s~
0
172
Member Avatar for Hamrick

I was playing with a bunch of new things today and came up with this. Did I do anything wrong? [code=c++] /* binary class manipulator Print values or strings as binary by Kimberly Hamrick */ #include <iostream> // for C++ I/O #include <string> // for C++ strings using namespace std; …

Member Avatar for Hamrick
1
207
Member Avatar for slacke

[QUOTE]Which process reads the data from it?[/QUOTE] All of them. :) Each process gets a handle to stdin and the computer makes sure that they all get a chance to read from it, but only one at a time.

Member Avatar for slacke
0
105
Member Avatar for Hamrick

I wrote strlen() for practice but it's really slow. Even if I copy the code from my compiler and run it, it's still slow. This is my test. [code=c++] /* strlen_comp Comparing my and Visual C++'s strlen by Kimberly Hamrick */ #include <assert.h> // for result tests #include <string.h> // …

Member Avatar for Hamrick
0
291
Member Avatar for quintoncoert

I bet there's an include path for libraries in the project settings. You should look there and see if you can find anything.

Member Avatar for Hamrick
0
163
Member Avatar for budin
Member Avatar for Duki
0
285

The End.