3,183 Posted Topics
Re: > I read its bad to use conio.h, and i use getch() from that header. If i have a new project that needs such function, is it good i to write it on my own? What would the mass of programmers do? getch() is "bad" because it's non-portable. Whether it's … | |
Re: Thanks for the input nikita, but was it really worth bumping a 7 year old thread that already had working example code? | |
Re: Dude, I'm not against helping you, but you need to read our rules: > #Keep It Organized * **Do** provide evidence of having done some work yourself if posting questions from school or work assignments If you continue to post nothing but homework questions without any evidence of thought or … | |
Re: Vertical tab and form feed are exactly what you'd think, and they really only apply to things like line printers or ancient hardcopy terminals. Note that those were part of the language way back in the 60s where such things were far more common than now. You're not likely to … | |
| |
Re: Here's an example of serializing non-POD types: #include <fstream> #include <iostream> #include <sstream> #include <string> #include <vector> #include <ctime> using namespace std; struct Info { string description; int quantity; double wholesale_cost; double retail_cost; string date_added; Info() {} Info(string const& s) { deserialize(s); } string serialize() const { ostringstream oss; oss … | |
Re: You can post directly to the Software Development category if there's not a sub-category that fits your needs. | |
Re: Your description is somewhat vague, but it sounds like you're looking for a graph. What exactly are you trying to accomplish with this data structure and algorithm? Explaining the ultimate goal of the feature as opposed to speculating about how it might be implemented will help third parties (like us) … | |
Re: When you display $num_result to the page, what's the value? echo var_dump($num_result), '<br />'; | |
Re: I'm not sure the first parameter is needed unless it refers to the modulus, but that's a fixed number, IIRC. What library are you using? Do you have the source code? If so, what does the body of that function look like? | |
Re: > void foo(string & s = "default"); Make it a const reference: void foo(string const& s = "default"); It's really no different from just calling a function taking a reference with a string literal: #include <string> using namespace std; void foo(string&) {} int main() { foo("test"); // Error, "test" is … | |
Re: > static const char *Error\[]; This is only a declaration, you still need to define Error: class Inventory { static const char *Error[]; ... }; const char *Inventory::Error[100]; 100 in this case is an arbitrary number, but since it's an array you need to pick something. | |
Re: > Have your boss put a constrain on you that you should only use standard library. However you could do it. Not with standard C++ since there's no concept of a directory, but using the system's standard API or a wrapper on top of it you certainly could. For a … | |
Re: You would need to push_back() each element after creating a new vector with push_back(): while (!done) { // Somehow populate inputs with an unknown number of elements (23 or less) int n = /* Number of actual elements in inputs */ data.push_back(vector<int>()); // Append a new vector // Populate the … | |
Re: > data.read(reinterpret_cast<char*>(corpData), sizeof(corpData)); This is an exceptionally bad idea because the Division type (of which corpData is an array) contains non-POD object types, std::string to be precise. You can't safely treat non-POD types as sequences of bytes for two very importan reasons: 1. The structure of the object is dependent … | |
Re: > That's all fine and dandy but it does NOT explain the fact that my strings change their values for no apparent reason. Yes, it does. Let's do a little visualization: a b --------- | | | | | --------- Copy "12\0" to a (note how a isn't big enough, … | |
Re: [This page](http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx#heap) has a good explanation with several different code variations. Read through that and if you have any specific questions, I'll be happy to answer them for you. | |
Re: I don't get that error in Visual Studio, GCC, or Comeau. What compiler are you using? | |
Re: Assuming you meet the requirements of LGPL, it seems that way. This is cool, I wasn't aware Qt had moved to an open source library model. That's what had kept me from using it. :) | |
Re: Have you read the [Starting C](http://www.daniweb.com/software-development/c/threads/50370/starting-c-#post234971) sticky? | |
Re: Some of those overlap with the standard C# library, what's the benefit of using your versions? | |
Re: > Although the pros of this he gave were strong (so that it was adopted), it still doesn't sit right with me. Coding styles are built on good arguments. If you couldn't come up with any cons for his method then there's no reason not to use it. Case in … | |
Re: What's the format of the file? Is the number being read as a string or an int? Is the file being opened as binary or text? There are a number of things that could throw a wrench into any solution, so you need to provide more information. | |
Re: Have you searched previous questions of this nature? Writing a compiler isn't a trivial feat, and C++ is an especially difficult language to process. Your best bet is to start by learning how to write a very simple compiler and then slowly expanding on what you learn. Don't expect to … | |
Re: > real_T add(real_T x, real_T z); And where is add() defined? The error is saying that you have a declaration for the function, but no definition exists and therefore it cannot be called. | |
Re: > As I have tested in VC++, if I use queue from <queue> and call any of these functions for an empty queue, program crashes. If the queue is empty, what were you expecting a reference to by calling front() or back()? This is a case of undefined behavior, which … | |
Re: > it's not homework It's close enough. > i have a final exam and this question was in one of the final exam sample > i just want to know how to solve it. I have an idea, how about you try to solve it and we'll help out when … | |
Re: > When you call a function, you do not but a space between the function name and the open bracket. You've pointed out a case of total irrelevance. Whether the space is there or not changes absolutely nothing, though I agree that it's recommended to be consistent with whatever style … | |
Re: What have you done so far to complete the task aside from starting this thread in the hopes that someone will give you the answer? | |
Re: Please post in English. On top of not conforming to our rules, you're limiting the number of people who can (or will choose to) help you by asking questions in French. | |
Re: Can you post a complete program that exhibits the problem? cout should be smart enough to treat chars and strings differently from integer types, so I suspect the snippet given isn't entirely accurate compared to what you're actually testing. | |
Re: How many supported phrases do you ultimately want? If it's only a handful like in the example program, even chains of if statements will be more than fast enough. Walt's suggestion of binary search is the next step, followed by perhaps a binary search tree. If you want a *lot* … | |
Re: > Do you want to say that, if i define pointer to a char,it doesn't reserve the memory for entering a string?? Exactly. > However, my problem being, the below code does take the string,prints it in the 6th line, but doesn't print the character at the adress. Your problem … | |
Re: Yes, there are many things the editor converts that the Markdown parser doesn't. Unfortunately, we use an editor with an especially obtuse and finicky parsing algorithm, so I've had trouble customizing it without making Dani nervous. ;) The posted result is what should happen, sadly. So keep an eye on … | |
Re: The error suggests that you have two main() functions, which isn't allowed in C++. | |
Re: > and the .h is depreciated in the C++ language nowdays. You mean deprecated, and that's still not correct. Deprecated is a term used for standard C++ features that have been superseded by another feature and are no longer recommended for use because they may be removed from the standard … | |
Re: It's not "working". When you lie to printf() you invoke undefined behavior, which *could* result in a seemingly valid value being printed. | |
Re: One thing to note is that difftime() returns a double. If you then cast the result to int, any precision is lost. Another common issue when difftime() appears to return 0 and the dates are clearly different is using the wrong specifier with printf(). Can you post a small, complete … | |
Re: > i have gone through some books and sites but, the explanation is very complex......:( Try [this one](http://eternallyconfuzzled.com/arts/jsw_art_bigo.aspx). | |
Re: time_t isn't a compatible type with unsigned int, which srand() expects as an argument, so the implicit conversion fails. You can take the easy way out and cast the result of time() to unsigned int: srand((unsigned)time(NULL)); However, be warned that this conversion technically isn't portable. But in practice, the chances … | |
Re: I quote each on in a single post, in the order that they appeared. You can quote one of three ways: 1. Select the text you want to quote and click inside the reply box. The text will be pasted and quoted automagically. 2. Manually paste the text with a … | |
Re: You can use mktime() after populating a tm object with the suitable date. Then the comparison can be done with difftime(): #include <stdio.h> #include <stdlib.h> #include <time.h> time_t get_today(struct tm** date, int is_gmt) { time_t now = time(NULL); if (date) { *date = is_gmt ? gmtime(&now) : localtime(&now); } return … | |
Re: If all you're doing is excluding the 'b's then it's as simple as this: for (i = 0; i < length; i++) { if (writtenStuff.charAt(i) != 'b') { Console.out.print(writtenStuff.charAt(i)); } } | |
Re: 1. If the search string is "abcdefg" and the search key is "xyz", there's no point searching beyond 'e' because a shorter search string than the key is guaranteed to not match. 2. `test` is an abritrary label for the break statement. If it doesn't exist, the continue and break … | |
Re: > you have to create a parse tree of the float chart, then you can do a depth first search to get the contents of the parse tree and create your pseudo code. if you are not familiar with the depth first algorithm, this is how it works, you have … | |
Re: > How about making a temporary 3 x 4 array, initialize it as you have done, then in your for loop, do a memcpy of the 3 x 4 array to the address of element array[T][0][0]? That's fine for arrays of built-in types, but if you're working with a non-POD … | |
Re: Allow me to deconstruct the code into what I believe are the relevant lines: > CImg <float> inImage(inputImage, image_width, image_height); > float *WrappedImage, *UnwrappedImage; > WrappedImage = inImage; > free(WrappedImage); If CImg handles its memory internally as one would expect, I see nothing good coming out of that call to … | |
Re: You're overrunning the end of the array in the sorting algorithm. The inner loop should stop at 8 rather than 9, because inside the loop you're referencing the index at `i + 1`. | |
![]() | Re: > The end result looks like this: > > Input number: 34 > array[0] = 34 > > Input number: 23 > array[0] = 34 > array[1] = 23 > > ... > and it keeps going until your desired break loop condition. That seems like a situation where a … |
The End.