436 Posted Topics

Member Avatar for bubblellicious

Distance between the two strings? Do you mean the Levenshtein distance or something else?

Member Avatar for Dream2code
0
101
Member Avatar for dzhugashvili
Member Avatar for dzhugashvili
0
557
Member Avatar for tatyakadam

That would happen if you do this: [code] C:\> tcc Sample1.c C:\> tcc Sample2.c [/code] The linker errors because those two calls to tcc are separate. They both try to compile and link the file, but there is no definition of f1 when compiling and linking just Sample2.c. To get …

Member Avatar for Dream2code
0
98
Member Avatar for Jammie

If the two strings are not sorted, the 'best' way depends on what trade off you want to make. If you want to have a small memory footprint but slower algorithm your way is fine. If you want to have a faster algorithm at the cost of more memory, two …

Member Avatar for Jammie
0
867
Member Avatar for neerajanamratha

Start by loading the DLL with the [URL="http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx"]LoadLibrary[/URL] function. Then if the name you want is in the DLL's export table, you can call [URL="http://msdn.microsoft.com/en-us/library/ms683212(VS.85).aspx"]GetProcAddress[/URL] to get a handle to it. Here is an [URL="http://msdn.microsoft.com/en-us/library/ms686944(VS.85).aspx"]example[/URL] program that does everything.

Member Avatar for neerajanamratha
0
2K
Member Avatar for sdmahapatra

[QUOTE]I have a function under Base class and at the definition tine of this base class function I need to call another function which is define under the Derived class. how to do this??[/QUOTE] Make the method virtual and protected in the base class, then override it as public in …

Member Avatar for Laiq Ahmed
0
226
Member Avatar for urbancalli

[QUOTE]How could I modify this so that when I edit a file and save it, it won't have to go through about renaming it and saving it again as if it is a new file?[/QUOTE] Most files are too variable to edit in place. Here are some guidelines for working …

Member Avatar for Tom Gunn
0
221
Member Avatar for daviddoria

Flip your first thought around. If Scan has a pointer to a Scanner, the constructor can take an argument of [ICODE]this[/ICODE] from the Scanner object generating the Scan object: [code=cplusplus] class Scanner; class Scan { Scanner *_scanner; public: Scan(Scanner *scanner): _scanner(scanner) {} }; class Scanner { public: Scan GenerateScan() { …

Member Avatar for Tom Gunn
0
121
Member Avatar for Uttumi

[QUOTE]Is this array initialization static or dynamic?[/QUOTE] C++ does not allow an array with a size that is not constant. If your compiler compiles that declaration and it runs, then the documentation will tell you how it works. I assume it has the same behavior as an array created with …

Member Avatar for John A
0
247
Member Avatar for Tom Gunn
Member Avatar for ryancfc

There is not a portable way to set a window title. The best you can do is have something like a appsys.h header with all of the non portable stuff: [code=cplusplus] #ifndef APPSYS_H #define APPSYS_H bool ChangeConsoleTitle(const char *title); #endif [/code] [code=cplusplus] #include <windows.h> #include "appsys.h" bool ChangeConsoleTitle(const char *title) …

Member Avatar for ryancfc
0
132
Member Avatar for kangarooblood

Why do you want an array? The string class will work for both sides of the encryption: [code=cplusplus] int main() { string word, dword; // read a word for (string::size_type x = 0; x < word.length(); ++x) { dword += Crypt(word); } cout << word << '\n' << dword << …

Member Avatar for kangarooblood
0
270
Member Avatar for faraheneh

NRU is a caching algorithm based on time. Cache some data and when the data is used set a flag bit. At regular intervals, check the flag bits and deallocate the memory for any of the data where the bit is not set. NRU means not recently used inside the …

Member Avatar for Tom Gunn
0
88
Member Avatar for jephthah

First I get attacked for not being perfect right out of the gate. Now I get attacked for fitting in. What do you want from me? :confused:

Member Avatar for ~s.o.s~
0
577
Member Avatar for born_to_code

I guess this is homework, but if it is not, the library already has this stuff: [code=cplusplus] #include <algorithm> #include <iostream> #include <iterator> #include <set> #include <string> using namespace std; // use basic_string<T> to allow any char type template <class T> basic_string<T> Intersection( const basic_string<T>& a, const basic_string<T>& b) { …

Member Avatar for Tom Gunn
0
1K
Member Avatar for thr

[QUOTE]you wont get any benefits from it and i dont even see a specific use[/QUOTE] I think it is a great way to explain the simplicity of C++. You will have to fight off the newbies wanting to learn if you show them the clear and intuitive code that can …

Member Avatar for thr
0
101
Member Avatar for chaines51

[QUOTE]Is there ANY standards compliant way to get unbuffered input from the console without the characters being automatically displayed?[/QUOTE] Short answer, no. The console does its own buffering, and then C++ does another level of buffering for performance. [U]You can change C++'s buffering, but that only affects performance[/U]. By the …

Member Avatar for chaines51
0
440
Member Avatar for donny_boyIT

Find out what processes are taking up all of your physical memory and kill them or increase your physical memory. Dipping into virtual memory too much is a bad thing because it is much slower than real memory. You can increase the virtual memory space, but that's probably just a …

Member Avatar for Tom Gunn
0
62
Member Avatar for Dream2code

[QUOTE]What is problem with memory occurs here?because the code will run fine>[/QUOTE] It is called a memory or resource leak. The memory you allocated from the first call to malloc is never freed, and for the rest of the program it will stay allocated and cannot be used anymore because …

Member Avatar for Dream2code
0
126
Member Avatar for Yaserk88

Why not change the locale to something that uses ',' as the radix character? Then you don't have to do any mumbo jumbo with strings: [code=cplusplus] #include <iostream> #include <locale> #include <sstream> using namespace std; int main() { istringstream is("12,34"); double a = 0; is.imbue(locale("german_germany.1252")); is >> a; // will …

Member Avatar for Yaserk88
0
2K
Member Avatar for sdmahapatra

Code guards will work everywhere, but [ICODE]#pragma once[/ICODE] will only work if the compiler supports it. What's worse, one compiler might define [ICODE]#pragma once[/ICODE] to do the same thing as code guards and another compiler might define it to do something completely different. Your code would break on the second …

Member Avatar for sdmahapatra
0
134
Member Avatar for barige rajesh

[QUOTE]Even the delete operator is executed, the last two output statements are working same the first two output statements.. How is this possible...????????????????? [/QUOTE] When you free memory, it may or may not be reused immediately for something else. If it is not reused, you can still access the pointer …

Member Avatar for barige rajesh
0
229
Member Avatar for VernonDozier

[QUOTE]Isn't the memory released automatically when the program ends?[/QUOTE] Yes and no. It depends on how your OS handles processes, but unless you work with some obscure or legacy systems, it is pretty safe to assume that when the program ends, all heap memory allocated to the process is freed …

Member Avatar for wildgoose
0
188
Member Avatar for dumrat

[QUOTE]I want to not see any warnings at all when I build.[/QUOTE] I haven't seen many warnings that were so asinine they could be completely ignored. Disabling warnings just so you can get a clean compile is not a recommended practice because fixing them almost always makes your code better. …

Member Avatar for Tom Gunn
0
431
Member Avatar for tazboy

[QUOTE=tazboy;919382][CODE]if ( infile ){ list = read_file( &infile, &lines ); infile.close(); }[/CODE] I did this and I still get the same result. When I cout << infile I get an address the first time and 0 the next time.[/QUOTE] Ancient Dragon already said you needed to clear the errors too. …

Member Avatar for tazboy
0
145
Member Avatar for Yaserk88

[QUOTE=Ancient Dragon;919847]>>char EVENT_NAME; That only declares a single character. you need an array, such as [icode]char EVENT_NAME[255];[/icode] or better yet [icode]string EVENT_NAME;[/icode][/QUOTE] Please remember that if you use an array with operator>>, you also need to lock the upper limit so that cin does not overflow the array: [code=cplusplus] char …

Member Avatar for Yaserk88
0
118
Member Avatar for san_sarangkar

[QUOTE]in order to be able to overload an operator<<,it must be declared as the friend of the class.[/QUOTE] Only if the overloaded operator needs access to the private or protected members of the class. If you only touch the public interface, the operator does not need to be a friend: …

Member Avatar for Tom Gunn
0
148
Member Avatar for calicocat

There is not a short and easy way to do that. If you need to search your variables for matching values, then they're related enough to put in an array: [code=c] int a[] = {4, 2, 4, 4}; [/code] And if you need to keep the names, it's only slightly …

Member Avatar for Dream2code
0
96
Member Avatar for nanchuangyeyu

If all of the fields have an overloaded copy constructor or assignment operator, or if they are built in types, you can just do assignments of all fields and everything should work right: [code=cplusplus] // use copy constructors and initialization CMatrix::CMatrix(const CMatrix& m) : _s_row(m._s_row), _s_col(m._s_col), base_mat(m.base_mat) { // all …

Member Avatar for Tom Gunn
0
108
Member Avatar for dchunt

It looks like you want a 2D array: [code=cplusplus] int P[] = { {0, 1, 1, 2}, {0, 3, 1, 0} }; for (int x = 0; x < 2; ++x) { for (int y = 0; y < 4; ++y) cout << P[x][y] << ' '; cout << '\n'; …

Member Avatar for Tom Gunn
0
153
Member Avatar for hwaterboys

This might help: [code=cplusplus] #include <iostream> using namespace std; int main() { const int size = 5; int a[] = {1, 2, 3, 4, 5}; int k = 0; for (int x = 0; x < 13; ++x) { cout << x << ": " << a[k++ % size] << …

Member Avatar for hwaterboys
0
123
Member Avatar for oopg

You are not allocating any memory that needs to be freed. You are using FILE pointers, so you need to call fclose() on each one, but that's all. Can you be more specific about what the problem is?

Member Avatar for Ancient Dragon
0
279
Member Avatar for GWalk612

[QUOTE][CODE] DynStack<double> doubleStack(); DynStack<float> floatStack(); [/CODE][/QUOTE] C++ syntax is kind of weird here. The compiler thinks you are trying to declare two functions, not instantiate two objects. For named objects, the default constructor does not need parentheses, and the syntax no longer looks like a function: [code=cplusplus] DynStack<double> doubleStack; DynStack<float> …

Member Avatar for Tom Gunn
0
126
Member Avatar for daviddoria

The method is marked as const, so calling find on DoubleValues will use the overload that returns a const_iterator. You can't assign a const_iterator to an iterator, but because the method is const, it should be safe enough to change the iterator like this: [code] bool OrientedPoint::getDoubleValue(const std::string &ValueName, double …

Member Avatar for daviddoria
0
6K
Member Avatar for daviddoria

The overload is not needed. As long as the function parameter is a const reference to string, you can pass a string constant and it will become a string object. Libraries usually have the overload to avoid the cost of constructing a new string object, but it is not required.

Member Avatar for daviddoria
0
114
Member Avatar for tig2810

How about a list of objects that represent the data: [code=csharp] class Cost // needs a better name { public string Code { get; private set; } public string Description { get; private set; } public double Amount { get; private set; } public double ExchangeRate { get; private set; …

Member Avatar for serkan sendur
0
178
Member Avatar for NathanOliver

[QUOTE]i would like to ask if this method should be called after ever cin statement?[/QUOTE] For anyone else reading, the method in question is [URL="http://www.daniweb.com/forums/thread90228.html"]here[/URL]. This thread used to be a post in that thread. operator>>() is the problem child here. It works something like this: [code=cplusplus] // beware: pseudo-code …

Member Avatar for NathanOliver
0
127
Member Avatar for tangent03
Member Avatar for Ragoune

[QUOTE]This is just copied from an example, so I don't know exactly what it means. The only thing I actually know is that the word 'export' is defined.[/QUOTE] [ICODE]__declspec(dllexport)[/ICODE] is the magic incantation to add a name to the export table of a DLL. [ICODE]extern "C"[/ICODE] is C++'s way of …

Member Avatar for Ragoune
3
192
Member Avatar for Embroidery

Any tutorial on the basic language will cover loops and arrays. Do you have more specific requirements for the program? It is hard to help with something vague like 'loops and arrays'.

Member Avatar for AirGear
-1
91
Member Avatar for theashman88

That's a lot of stuff to look at. Can you boil it down to something small enough to post in code tags?

Member Avatar for tux4life
0
247
Member Avatar for Ather14

[QUOTE]I want to add a string of numbers(e.g 9999) which are stored in a text file.[/QUOTE] Are you just adding the digits? If so then for each character that is a digit, you can subtract '0' from it to get the integer value: [code] '0' - '0' = 0 '1' …

Member Avatar for Ancient Dragon
0
977
Member Avatar for Hiroshe

2D array arguments need a size for all but the first dimension. If you don't know the size until run time, or the function has to take different sized 2D arrays, you can use a pointer to a pointer instead. Then the calling code can either allocate memory to a …

Member Avatar for Hiroshe
0
10K
Member Avatar for daviddoria

[QUOTE]it seems to me if you don't use pointers then you never have memory leak type problems...[/QUOTE] I wish that were so. :( Raw pointers are dangerous, and that's why smart pointers and RAII are so important. Even if you use the troublesome auto_ptr, your leak problem can be fixed: …

Member Avatar for Ancient Dragon
0
96
Member Avatar for nirav99

[QUOTE]>I just thought syntactically that it was incorrect No it isn't. Syntactically it is fine but it is deprecated.[/QUOTE] Just because you don't like a feature or it was inherited from C doesn't make it deprecated. ;) To the best of my knowledge, (void) parameter lists are not deprecated. Please …

Member Avatar for Tom Gunn
0
147
Member Avatar for Emerald214

[QUOTE]1) This is exactly what I'm encountering. I googled for that but none of those posts talked how to do this: member function B::fb makes a call to _beginthreadex with thread function which is a member function ( A::fa ).[/QUOTE] Google probably doesn't talk about it because that is not …

Member Avatar for Emerald214
0
205
Member Avatar for csayantan

[QUOTE]Wouldn't a simple If Not Defined wrapped around the include solve the "conflict"?[/QUOTE] Yes. Even better is the usual convention of wrapping everything in the header with a conditional compile test: [code=cplusplus] #ifndef HEADER_H #define HEADER_H // header contents #endif [/code] Then it doesn't matter how many times the header …

Member Avatar for Tom Gunn
0
189
Member Avatar for xyzt

Without more code to look at, I can only guess. But my guess is that he didn't include the right header for strdup and casted the result to silence his compiler's warnings about it.

Member Avatar for xyzt
0
95
Member Avatar for nonadoes

This is what sscanf was born to do: [code=c] #include <stdio.h> int main() { const char *p = "TAGNAME_C123_V45_S67_M89"; int c, v, s, m; if (sscanf(p, "%*[^_]_C%d_V%d_S%d_M%d", &c, &v, &s, &m) == 4) { printf("C=%d\nV=%d\nS=%d\nM=%d\n", c, v, s, m); } return 0; } [/code]

Member Avatar for nonadoes
0
220
Member Avatar for rtwister

You can declare a function without defining it if you replace the curly brackets and code with a semicolon: [code=cplusplus] void Menu(); void McDonalds() { // ... } void Menu() { // ... } [/code]

Member Avatar for Tom Gunn
0
77

The End.