- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 7
- Posts with Upvotes
- 7
- Upvoting Members
- 6
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
30 Posted Topics
Re: [QUOTE]just tried using fgets() (see below) but I run into message "warning: passing argument 1 of ‘fgets’ makes pointer from integer without a cast"[/QUOTE] fgets() requires an array of char for the first argument. [code] #include <stdio.h> int main() { char input[BUFSIZ]; printf("\nTo calculate a^b, enter value a now.\n"); int … | |
Re: [QUOTE]Is this dynamic array procedure something that's not suitable for use with objects?[/QUOTE] Dynamic arrays work with objects, the problem is the value of the static variable Fuzzy::n. Destructors are only called if the memory is freed, so if you create an array of 10 in the first iteration of … | |
Re: When I was in school, we were expected to do our own homework. Has this changed? | |
Re: celltype is wrong because the function is hashing the student ID. The list is irrelevant to that task. x should have a type of student instead. Concerning sum, first and foremost it must be initialized. The += operator uses the current value within sum and adds to it, if sum … | |
Re: [QUOTE]I have been advised by many people that it is better to use integer return type for main function instead of void ![/QUOTE] That is good advice if you want the code to be maximally portable without any changes. [QUOTE]I actually dont understand what return 0 means[/QUOTE] It means the … | |
Re: There are two logical parts to an array. The [B]capacity[/B] is set by the declaration. For the declaration [icode]int a[10];[/icode], 10 is the capacity. It is the maximum number of elements that can be stored in the array. The [B]size[/B] is the number of used elements in the array. Using … | |
Re: My guess is that GetSymbol() returns a void*, and void* is not compatible with function pointers. Try a cast, you might get lucky. [code] helloSteve myFunc = reinterpret_cast<helloSteve>(myDLL->GetSymbol(wxT("helloSteve"))); [/code] | |
Re: [QUOTE=mrkaran;1306567]if i have two strings say: string str1,str2; then how can i compare them by using strcmp function?[/QUOTE] The strcmp() works with C strings. The string class has comparison built in using both operators and the [URL="http://www.cplusplus.com/reference/string/string/compare/"]compare()[/URL] method. The compare() method is the closest match to strcmp(), but if you … | |
Re: The solution is to get a newer compiler and use graphics libraries that are better suited to Windows 7. Turbo C++ can probably be made to work through extreme compatibility, but it was written for Windows 3.1 and is so far out of date that new code should not be … | |
Re: floats can be used as a counter, but you must be very careful in comparing them because they are approximations of values and have inaccuracy where two values that seem the same are not exactly the same. A fuzzy comparison is usually used for floating point. Here is your code … | |
Re: There is no function to do this kind of numeric formatting, but one can be written. The hardest part is the group separation with commas. [code] #include <stdio.h> #include <string.h> #include <limits.h> #include <locale.h> #include <ctype.h> typedef enum { FALSE, TRUE } BOOL; BOOL format_numeric(char const* num, char* buf, int … | |
Re: In what way is it not working? The same code works ok for me. [code] #include <iostream> #include <iomanip> #include <string> using namespace std; int main() { string a = "hello"; cout<<"|"<< setw(10) << a <<"|"<<endl; } [/code] | |
This function reformats a numeric sequence to include grouping in the usual human readable format. "123456789" becomes "123,456,789", for example. The formatting is localized to the current running machine. In a German locale the previous example becomes "123.456.789". In a Hindi locale it becomes "12,34,56,789". Printing numbers for human consumption … | |
Re: The parentheses around void seem to be the problem. Does this produce the same error? [code] struct { void (*function)(); const char* functionName; } lookUpTable[] = { {&TSL1_ReadMemory32, "ReadMemory32"}, {NULL, NULL} }; [/code] | |
Re: Because of how RLE works, a run of two will not naturally be in the encoded string. You can use a run of two of any character as a special sequence that signifies the start of an encoded run for that character. In your example, "ABRTTTTOPSSSSSNU" becomes "ABRTT4OPSS5NU" with the … | |
Re: [QUOTE]For any other object that is not the "this" object, protected members are inaccessible, just like if they were private, as far as Foo is concerned or any other derived class for that matter.[/QUOTE] What you say is not completely correct, for the following code compiles and runs. [code] #include … | |
Re: [CODE]connections[k++]=&(slot(ii,jj));[/CODE] This line is suspicious. If connections is a vector, then either it should be resized to have enough space beforehand, or push_back should be called to add a new element each time. Indexing does not resize the vector, that might be why the size is different from how many … | |
Re: This is what is called a dependent type because the type of the vector size_type is dependent on is also dependent on a template argument. It is fixed with the typename keyword. [code] template <class Type> class Some { private: vector<Type> elements; typename vector<Type>::size_type index; public: Some() { } }; … | |
Re: strcat_s() takes 3 arguments, not 2. And just like strcat(), a precondition is that the string is already zero terminated. Meet the precondition and supply the required arguments and it will work as expected. [code] person1.m_name[0] = '\0'; strcat_s(person1.m_name, 40, "Dan"); [/code] For initialization, strcpy() or strcpy_s() are better choises. | |
Re: [QUOTE=mike_2000_17;1303930]the (int) cast is from C, and is not recommended in C++ for good reasons. Use the "functional" casting: [CODE] //check the video info header Width = int(&pVideoInfoHeader->bmiHeader.biWidth); Height = int(&pVideoInfoHeader->bmiHeader.biHeight); //break point here [/CODE] [/QUOTE] The functional cast is still the same thing as the C cast, and it … | |
Re: Did you prefix the name with the namespace? [code] std::nth_element(minRollArray, minRollArray+n, minRollArray+numSets); [/code] | |
What are good name conventions for classes. How for example should the name be different between a base class and a derived class or an abstract class and a concrete class? | |
Re: Looping over the string keep in mind that the code is looking for a single instance of the character type. Avoid breaking the loop until the end. Your code does not work because the first loop in verifyPass returns false if *any* of the characters in the whole string is … | |
What are some good exercises for an experienced programmer new to C++? I have found lists and suggestions on the web, but they are always simple or I have already completed them in other programming languages like C or Basic. Something that will help with learning modern C++ is best. | |
Re: cell should not be dereferenced in the first call to malloc(), and the cast is missing a level of indirection. [code] cell = (s_cell**)malloc(sizeof(s_cell) * MAP_X); [/code] | |
Re: [QUOTE]if you want to make a gui program that is not all DOS, and command prompt, then why use C++[/QUOTE] You can say the same about any other programming language. Java for example has a GUI library, but it is not part of the language. You still have to learn … | |
Re: Cut off the upper end of the range to account for the addition. [CODE]rand() % (20-8) + 8[/CODE] | |
Re: [QUOTE]1) Get a IDE, I suggest one of these, codeblocks or visual studio 2008.[/QUOTE] Visual C++ 2010 is better because it has parts of the newest C++ and the IDE is much improved. Visual C++ 2008 is still good, but if old projects do not need to be maintained then … | |
Re: What kind of help do you need? Are there errors that you do not understand? | |
Re: [QUOTE]I thought ffgets second argument would limit the input, but it doesn't. Any help is appreciated.[/QUOTE] fgets *does* limit the input. But only for the buffer argument to fgets. To print an error if there is more input than the buffer can hold, check for a new-line character at the … |
The End.