3,183 Posted Topics

Member Avatar for coffecat

> 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 …

Member Avatar for Schol-R-LEA
0
324
Member Avatar for lostinthespiral

Thanks for the input nikita, but was it really worth bumping a 7 year old thread that already had working example code?

Member Avatar for deceptikon
0
833
Member Avatar for tubzz

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 …

Member Avatar for tubzz
0
192
Member Avatar for sunfutbol

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 …

Member Avatar for WaltP
0
178
Member Avatar for phorce
Member Avatar for Schol-R-LEA
0
136
Member Avatar for Sendy Hipo

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 …

Member Avatar for Sendy Hipo
0
614
Member Avatar for M.Waqas Aslam

You can post directly to the Software Development category if there's not a sub-category that fits your needs.

Member Avatar for Dani
0
204
Member Avatar for Akill10

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) …

Member Avatar for skatamatic
0
116
Member Avatar for omoayan

When you display $num_result to the page, what's the value? echo var_dump($num_result), '<br />';

Member Avatar for omoayan
0
141
Member Avatar for Simone Z.

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?

Member Avatar for Simone Z.
0
2K
Member Avatar for OrangeTree

> 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 …

Member Avatar for OrangeTree
0
154
Member Avatar for Clouded One

> 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.

Member Avatar for Clouded One
0
147
Member Avatar for OrangeTree

> 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 …

Member Avatar for OrangeTree
0
245
Member Avatar for zenitis

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 …

Member Avatar for deceptikon
0
177
Member Avatar for Sendy Hipo

> 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 …

Member Avatar for Sendy Hipo
0
183
Member Avatar for Epickup

> 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, …

Member Avatar for Epickup
0
149
Member Avatar for R1111

[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.

Member Avatar for R1111
0
208
Member Avatar for SCass2010

I don't get that error in Visual Studio, GCC, or Comeau. What compiler are you using?

Member Avatar for deceptikon
0
163
Member Avatar for daino

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. :)

Member Avatar for daino
0
117
Member Avatar for firdousahmad

Have you read the [Starting C](http://www.daniweb.com/software-development/c/threads/50370/starting-c-#post234971) sticky?

Member Avatar for firdousahmad
-1
107
Member Avatar for lxXTaCoXxl

Some of those overlap with the standard C# library, what's the benefit of using your versions?

Member Avatar for skatamatic
0
159
Member Avatar for jaskij

> 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 …

Member Avatar for two[ ][ ]
0
176
Member Avatar for tuputavieja

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.

Member Avatar for Sokurenko
0
121
Member Avatar for hanaac++

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 …

Member Avatar for hanaac++
0
99
Member Avatar for sriram_11

> 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.

Member Avatar for sriram_11
0
384
Member Avatar for MrEARTHSHAcKER

> 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 …

Member Avatar for MrEARTHSHAcKER
0
2K
Member Avatar for a2i2

> 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 …

Member Avatar for a2i2
0
187
Member Avatar for awesomeriley

> 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 …

Member Avatar for deceptikon
0
183
Member Avatar for Ouss

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?

Member Avatar for Sendy Hipo
0
306
Member Avatar for sara5454

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.

Member Avatar for sara5454
0
162
Member Avatar for Sendy Hipo

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.

Member Avatar for Sendy Hipo
0
131
Member Avatar for Dasttann777

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* …

Member Avatar for m4ster_r0shi
0
161
Member Avatar for nee_88

> 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 …

Member Avatar for Sokurenko
0
121
Member Avatar for WaltP

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 …

Member Avatar for WaltP
0
140
Member Avatar for whileiforelse

The error suggests that you have two main() functions, which isn't allowed in C++.

Member Avatar for whileiforelse
0
116
Member Avatar for Onlineshade

> 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 …

Member Avatar for mustaffa hasan
0
156
Member Avatar for Gaiety

It's not "working". When you lie to printf() you invoke undefined behavior, which *could* result in a seemingly valid value being printed.

Member Avatar for WaltP
0
110
Member Avatar for wan632

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 …

Member Avatar for WaltP
0
713
Member Avatar for dev90

> 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).

Member Avatar for Sokurenko
0
298
Member Avatar for Dann0
Member Avatar for lewashby

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 …

Member Avatar for Sky Diploma
0
238
Member Avatar for Techno22

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 …

Member Avatar for Techno22
0
113
Member Avatar for zur1ch

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 …

Member Avatar for zur1ch
0
100
Member Avatar for GeekTool

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)); } }

Member Avatar for GeekTool
0
111
Member Avatar for GeekTool

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 …

Member Avatar for deceptikon
0
492
Member Avatar for mrexp21

> 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 …

Member Avatar for deceptikon
0
2K
Member Avatar for NunsBeachSurfer

> 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 …

Member Avatar for mike_2000_17
0
301
Member Avatar for ollie60

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 …

Member Avatar for ollie60
0
238
Member Avatar for Zvjezdan23

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`.

Member Avatar for deceptikon
0
137
Member Avatar for SalicBlu3

> 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 …

Member Avatar for m4ster_r0shi
0
133

The End.