6,741 Posted Topics
Re: [QUOTE]it is not part of the standard C++ library[/QUOTE] It's available in C++11 though. | |
Re: nameList is uninitialized. Since you're always using realloc() to allocate memory to nameList, it should be initialized to NULL for the first allocation to succeed: [code] char** nameList = NULL; [/code] | |
Re: The usual methods of storing passwords aren't reversible, so the only option is resetting the password. You can then either email the new password to your users and give them the option of changing it, or invalidate the password and force them to change it rather than risk sending a … | |
Re: Please post a complete test program that exhibits the error. | |
Re: There's a rather large difference between pointers to functions and pointers to instance member functions. The latter is actually an offset rather than a true pointer, so the two are not interchangeable. [url]http://www.parashift.com/c++-faq-lite/pointers-to-members.html[/url] | |
Re: [QUOTE]Is it possible to do something like this with strtok()?[/QUOTE] No, strtok() doesn't support rules for embedded delimiters. What you want is more along the lines of a CSV parsing algorithm | |
Re: An INI file is as good as anything, given the lack of details about your application. | |
Re: [QUOTE]Should i create an Array of structures and copy the Information using the void Read_Info(void) function into each struct?[/QUOTE] Yep. This is fine for school assignments unless there's a specific requirement to handle huge files. It's vastly simpler to store all of the records in memory and then resort[*] as … | |
Re: >I just wanna know how to send a file through a socket connection in C language The same way you would send any other stream of characters. Just pretend the socket is an output stream and copy the file to it. | |
Re: [QUOTE]i wanna know what Mac Mini do SIMPLY[/QUOTE] It's a gimped Mac intended to fit the target market of a cheap computer with a small form factor. What does it [i]do[/i]? Everything a regular computer does, just slower. ;) | |
Re: Borland Builder has been primarily C++ (with C support) for many years. Another option is Microsoft's Visual C++ if you want a visual designer that's integrated into the IDE. | |
Re: Let's make it even more complicated. ;) B-Tree is an ambiguous term, and there are different versions that will wait until nodes are more full or less full before splitting. | |
Re: [QUOTE=zo0oda;1690381]thanx for replay..... I know what you say because i read about linked list and i knew the basics but i'm still waitting the code from someone .....[/QUOTE] I'm interpreting this as you know how to do it, but you're too lazy to do it yourself. Thus you came here … | |
Re: If I understand your question properly, you want to split and store strings rather than integers or single characters. While you could do it manually, that kind of ad hoc parsing is potentially tricky and more verbose than a similar solution using the standard library: [code] #include <stdio.h> #include <string.h> … | |
Re: You only need to show the invalid prompt if the entered value was actually invalid: [code] printf("Enter a positive number: "); fflush(stdout); /* I'm ignoring non-integer input for now to keep things simple */ scanf("%d", &x); while (x <= 0) { printf("Invalid input. Please try again: "); fflush(stdout); scanf("%d", &x); … | |
Re: [QUOTE]If you're like me and enjoy Steam's service (not having to mess with DVDs and CDs)[/QUOTE] I feel far more comfortable with media than steam. Also keep in mind that if you're playing on a PC, the modders will almost certainly offer a no-DVD patch so that the media will … | |
Re: [QUOTE]please tell me whether this code is right ??????[/QUOTE] No, we've already gone over this. The author of your book is a retard, and you can't trust any of the code in it. Actually, you can trust that the code is probably wrong in all examples. I can only imagine … | |
Re: Well, if you want to follow standard Windows interface guidelines, that information would be under the [B]Help[/B] main menu option. It should display a dialog with the information. You say you're using Visual Studio 2010, but that's not enough information. Is this a C++/CLI application using Windows Forms or WPF, … | |
Re: [QUOTE]And why these address are fixed.[/QUOTE] The addresses aren't fixed, but the likelihood of the addresses being right next to each other is pretty good. Here's my output (after fixing your Turbo C crap boilerplate): [code] Address of i=28ff18 value at ptr=10 Address of j=28ff14 value at ptr=20 [/code] Notice … | |
Re: [QUOTE]What I am wondering is, if I just declare an dynamic array with the size [0], I can still write to [1] for example.[/QUOTE] Why would you be able to use more memory than you allocated? [QUOTE]What would be the proper way of creating a dynamic array that changes its … | |
Re: When people say "comparison" in the context of a sorting algorithm, they typically mean comparing the items in anticipation of a swap. In the case of selection sort, the "comparison" would be where you're looking for the largest (or smallest) unsorted item. Here: [code] if (array[j] > array[bigIndex]) // This … | |
Re: [QUOTE]What else could cause a seg fault on the last line of code no matter what that line of code is?[/QUOTE] Corrupted memory that only manifests in the destructor is a good start. | |
Re: Well, arrays are indexed starting at 0, so if you want to map 1 to the first name, it would be [iCODE]users[index - 1][/iCODE]. Then all you need to do is ask the user to enter a number corresponding to the person they want to vote for. Your loop has … | |
Re: [QUOTE]How do you determine whether the input is a string, a double type or integer?[/QUOTE] The state of cin will tell you if there was an error. If you ask for an integer, for example, and the operation fails, it's fairly safe to assume that the user typed the wrong … | |
Re: Which three did you try? I have no problem with Microsoft, GNU, Borland, and Intel. Those are probably the top four for Windows platforms. | |
Re: [QUOTE]I have a text file with 10 lines, one word on each line and I am trying to get a word from a random line and then cout that word.[/QUOTE] Take note that since there's only one word on each line, the problem can be restated as trying to get … | |
Re: [QUOTE]If I knew what to do I would not posting here.[/QUOTE] What Walt meant is that if you don't show us your updated code, it's rather difficult to help you with the changes you made. | |
Re: Given the size difference, I'd say that your compiler implements virtual bases using a virtual base pointer (much like the better known virtual table pointer for polymorphism). Extra bookkeeping is required to maintain the shared instance, because the compiler can't simply stack the instances as in non-virtual inheritance. | |
Re: [QUOTE]Using a C but not a C++ compiler.[/QUOTE] Irrelevant. Both languages follow the same rule. [QUOTE]But I would like to know what the C standard really tells us here.[/QUOTE] The C standard says that it invokes undefined behavior. See section 6.2.2: [quote] If an object is referred to outside of … | |
Re: A rolling window would be the simplest solution, in my opinion, at least to get the last N lines: [code] #include <algorithm> #include <cstddef> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <string> using namespace std; namespace { const size_t N_LINES = 100; } int main() { ifstream in("filename"); … | |
Re: [QUOTE]I will have to trust that you understand the code below or else u are just screwing yourself over.[/QUOTE] If it's really for his girlfriend then he's screwing her over...and not in a good way. [QUOTE]there is no rule saying I cannot post code as long as I wrote it … | |
Re: What do you mean that it makes 0 comparisons? Because compiling as-is with a simpler driver, I get reasonable comparison results. | |
Re: [QUOTE]I am getting a segmentation problem in swap(a[m].a[k]); Please explain.[/QUOTE] The simplest form of debugging is debug messages: [code] k=(m+n)/2; printf("m:[%d] n:[%d]\n", m, n); swap(a[m],a[k]); [/code] Verify that your indices aren't out of bounds at any point during the algorithm, because that's the most likely cause of segmentation faults in … | |
Re: [QUOTE]As I know there is no disadvantages of OOP if I am not wrong.[/QUOTE] You're wrong. Go do a google search and educate yourself. | |
Re: [B]Encapsulation[/B] can have different meanings depending on whom you ask. Most of the time you'll see encapsulation rolled up along with data hiding, which while appropriate, is technically incorrect. My interpretation of encapsulation is strictly the bundling of data and behavior. In the case of C++, those would be the … | |
Re: [QUOTE]ALL arrays start at zero, or just most? [/QUOTE] It varies depending on the language you use. In pseudocode, just specify which one you want and go with it. Pseudocode is, after all, just a faux programming language that helps you think in code better than flowcharts. [QUOTE]Or do you … | |
Re: [QUOTE]although it is asking me "option-1", its skipping the "Ques-"[/QUOTE] My crystal ball says that the caller of quizquestion() is doing input using the >> operator, which leaves a newline in the stream for [iCODE]cin.getline(stmt,100)[/iCODE] to terminate on immediately. Try placing a cin.ignore() at the beginning of quizquestion(); I'm willing … | |
Re: By "add bytes" I assume you mean insert rather than overwrite, and the answer is no. For very large files you'd probably be better off working out a multi-file scheme where the point of insertion contains a reference to another file with the inserted data rather than the data itself. | |
Re: [QUOTE]That said, Android is far less dependent on a single source for both hardware and software, so is theoretically less fragile than is iOS.[/QUOTE] Though in practice that makes it [i]more[/i] fragile. I recently bought an iphone, and the reason is because the Android devices were too risky (and my … | |
Re: Helpful hints, hmm. How about don't be lazy? It's not like someone walked up to you on the street and gave you this assignment when you know zilch about trees. You must have learned something in class before your teacher gave the assignment, so posting up the requirements without trying … | |
Re: [QUOTE=MachDelta;1686106]Another newbie question here. What's the difference between these two? [CODE]cin.ignore(cin.rdbuf()->in_avail(), '\n'); cin.ignore(numeric_limits<streamsize>::max(), '\n');[/CODE] I understand that the former will ignore only the characters [I]left[/I] in the stream buffer, while the latter tries to ignore characters equal to the [I]size[/I] of the buffer. So the end result should, normally, be … | |
Re: Your question is confusing and suggests a misunderstanding about compilation. A programming language is the (usually textual) manifestation of a set of rules for specifying instructions to the computer. Because those rules are designed for human programmers, they're abstracted to a higher level and need to be converted into something … | |
Re: That's not a typical pyramid pattern for beginners. Can you provide a larger example? 10 rows, perhaps? | |
Re: [QUOTE]Sorts the values in ascending order according to the following algorithm, where size is the number of doubles to be sorted: for i=0..size-2 check all the values between position i and size-1 to find the smallest one swap the smallest value and the one in position i[/QUOTE] That's a description … | |
Re: [QUOTE]I noticed that, getting user imput, conditional statements, using escape charecters, exicuting system commands, and even declaring variables and using them so that they have use; these are all difficult outside of the domain of C and C++[/QUOTE] Hahaha! No. ;) [QUOTE]even the merciless Java can't do it without several … | |
Re: [B]>But perhaps there might be an easier way to do this?[/B] Well, if you don't want to do the if statement route (probably best in this case), you could go overkill and use qsort... [code] #include <stdio.h> #include <stdlib.h> int compare(const void *a, const void *b) { const float *ia … | |
Re: [QUOTE]In programming it's "Study & plan, then you can"**.[/QUOTE] That sounds goofy. How about "Get your shit together at design time rather than coding time". :D | |
Re: Google for a C++ Excel library. Alternatively you can use an OLE library to interface with Excel files, but either way you're looking at a third party library to do the heavy lifting. | |
Re: It really depends on how thorough you want to be, but I've found that the following triple whammy is sufficient most of the time: [list=1] [*]Make sure that your images are registered so that you can identify yourself as the copyright owner in the case that someone steals them. [*]Decrease … | |
Re: It's certainly confusing, but straightforward once the concept is understood. Formatted input methods ignore leading whitespace. Unformatted input methods don't ignore leading whitespace. The newline character is whitespace. Finally, getline() terminates when it detects a newline. So the pattern where getline() is "skipped" would be formatted input followed by getline(), … |
The End.