6,741 Posted Topics
Re: >This code compiles in VC++6.0 But it doesn't do what you seem to think it does. You're calling the constructor twice, thus creating [b]two[/b] objects. Only one of those objects do you pair with a variable. >Why does it do this way in visual c++? Because Turbo C++ is wrong … | |
Re: If your input is a C-style string, you can use strlen: [code] #include <cstring> std::size_t len = std::strlen ( buffer ); [/code] If your input is an std::string, it's even easier. Just use the size or length member functions. Alternatively, since it appears you're just reading a string, you can … | |
Re: >Is this something for a Beginner to do. CGI isn't something I would automatically recommend for a beginner, no. | |
Re: For non-leap years, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31. For leap years, add one to February using the formula: ((year MOD 4 = 0 AND year MOD 100 <> 0) OR year MOD 400 = 0) | |
Re: >Since it seems like this is just gonna go one for ever saying "it works for me" someone just lock this thread. Maybe you should be more specific than "it doesn't work". It sounds like you're experiencing the first problem that most Dev-C++ users ask here, where the output window … | |
Re: >Replace strcpy(buffer, holdingArray[1]) with buffer=strdup(holdingArray[1]). strdup isn't a standard function, so you shouldn't expect it to exist since there was no mention of which compiler is used. Fortunately, it's easy to write: [code] char *copystr ( const char *s ) { char *rs = new char[strlen ( s ) + … | |
| |
Re: >So the only difference is that members of a struct are public, and members of a class are private... Inheritance defaults to private for classes and public for structures too. Just remember that the default access for classes is private and for structures it's public. | |
Re: >But software? That just doesn't make any sense. Why not? A good understanding of the machine can improve code quality even in high level applications. As a good example, the system cache is becoming more and more important in high level data structures, and if you don't program with it … | |
Re: First make a stop at [url]www.wotsit.org[/url]. | |
Re: Even something as "simple" as color is platform and often compiler dependent. But I'll assume Windows and guide you [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setconsoletextattribute.asp]here[/url]. | |
Re: If you want any decent timings, you'll use a profiler. But you can use a poor man's timer with the standard library. For example: [code] #include <ctime> std::clock_t start = std::clock(); /* Stuff to time here */ std::cout<< ( ( std::clock() - start ) / (double)CLOCKS_PER_SEC ) <<'\n'; [/code] But … | |
Re: >Am i right Barring sneaky tricks, you're right. But anything is possible if you're desparate enough to come up with a workaround that might work. For example: [code] #include <stdio.h> void change() { #define printf(fmt,x) printf ( "%d\n", 5 ) } int main() { int i=5; change(); i=10; printf("%d\n",i); return … | |
Re: Have you tried the Visual Basic forum? It's not hard to find, being a top level category and all. | |
| |
Re: >I'm trying to implement a simple Cstring/Cstring map in my application >so users can specify what they want to see instead of the MAC address. The who and the what, now? It sounds like you want some sort of variant type, but I'm not sure. So be more specific and … | |
Re: >was interesting to learn bout binary trees.... Done already, eh? That's impressive. It took me at least a year before I was comfortable with a fraction of the stuff in those tutorials. So I guess you read them and absorbed all of the information in less time than it took … | |
Re: >Where can I find specific instructions? System and compiler documentation. | |
Re: I recommend Python as a first language. It's very forgiving, whereas my recommendation for a second language, C, is not. | |
Re: >I want to make.. Please use a more informative title next time. | |
Re: >What is a two way templatized linked list in C++? It's a standard container: [code] #include <iostream> #include <list> int main() { std::list<int> my_list; for ( int i = 0; i < 10; i++ ) { if ( i % 2 == 0 ) my_list.push_front ( i ); else my_list.push_back … | |
Re: No, you have to simulate a few keystrokes with the Windows API function keybd_event. IIRC: [code] keybd_event ( VK_MENU, 0, 0, 0 ); keybd_event ( VK_RETURN, 0, 0, 0 ); keybd_event ( VK_RETURN, 0, KEYEVEÂNTF_KEYUP, 0 ); keybd_event ( VK_MENU, 0, KEYEVENTÂF_KEYUP, 0 ); [/code] ![]() | |
![]() | Re: Don't try to bubble sort a linked list, it's bad enough for arrays. There are two sorting algorithms that lend themselves well to sorting linked lists: [url=http://www.eternallyconfuzzled.com/tuts/sorting.html#insertion]insertion sort[/url] and [url=http://www.eternallyconfuzzled.com/tuts/sorting.html#merge]merge sort[/url]. However, selection sort is also easy to visualize and to implement. ![]() |
Re: >I need to generate a unique filename in a directory other than c:\temp Is this a directory that you specify or just any directory other than C:\temp? If it's the latter then tmpnam will create the file in the local directory. If it's the former then you're SOL and need … | |
Re: >copying from one file to another is a simple matter. On the surface at least. >I'm wondering how this is done in C++ A direct translation of C streams to C++ streams is: [code] #include <fstream> int main() { ifstream in ( "infile" ); ofstream out ( "outfile" ); if … | |
Re: I would recommend asking for suggestions on [url=http://www.gamedev.net/]GameDev[/url]. They have resources for newcomers to game programming that Daniweb lacks. | |
Re: >1) What is causing these warnings the first time I compile? The complete identifier is saved for debugging purposes when you compile in debug mode. However, because the internal identifier for templates can be ridiculously long, and the compiler only allows a length of 255 characters, everything after 255 characters … | |
Re: We're not going to do it for you. What have you done so far? | |
Re: "Script" is a very broad term that typically doesn't apply to C or C++. Can you be more specific? | |
Re: >cout<<"Enter a["<<n-i<<"]:"; Gah! That's ugly. It could be formatted better to show the intention: [code] cout<<"Enter a["<< n - i <<"]:"; [/code] This basically prints "Enter a[[i]x[/i]]: ", where x is an index counting from the back of the array. If i is 0 and n is 5 then it … | |
Re: >Must the programmer Flag this as an error and allow the user to correct >his input or make the program correct it for the user That's up to the programmer. It's certainly easier in the general case to force absolute correctness from the end user, but the added convenience of … | |
Re: With your experience, you don't need more than a good reference. I learned C# from "The C# Programming Language". That coupled with the material on MSDN is more than enough to get started with some serious programming. | |
Re: Please don't start a new thread if your question isn't answered immediately. That said, there's no point in explaining the intricacies of a C++ implementation when you're so new to C++. Just take it on faith that there's a good reason, and expect to learn that reason when the time … | |
Re: >Sorry, change the "of any type" to "integers only". How about changing "macro to swap two arguments of any type" to "silly macro to break everything". It's still broken because you're modifying a variable more than once between sequence points. This isn't a difficult rule to figure out, I can't … | |
Re: Let me get this straight because your communication skills are lacking. You have a hash table with an exceptionally slow hash function (FNV would be faster, and since you need to handle collisions due to duplicates [b]anyway[/b], a cryptographic hash is a little much for table lookup). You're keying the … | |
Re: >This problem was ignored in the command line version No, you were just unlucky enough that it didn't fail with as sirens, bells, and confetti. >But this is a cop out. It's still wrong because structure members are allowed to have padding between them and the padding is off-limits. If … | |
Re: >It's one of the best C++ compilers out there, has the highest ANSI >compliance of them all (at least for the Win/Tel platform) and excellent performance. Um, no? Borland 5.5 is nice for an older compiler, but it's far from the most conforming, which is Comeau, and it fails to … | |
Re: >[COLOR=Red]cin[/COLOR].getline(linebuffer,100); This should be [code] [COLOR=Blue]file[/COLOR].getline(linebuffer,100); [/code] The program is stopping dead in its tracks because the loop is keyed on whether the file is empty or not, and you never read from the file, just standard input. Also, using eof() as a loop condition is wrong because the eofbit … | |
Re: >whereas cout is a just a 'class' with an output operator as ancient >dragon explained and therefore doesnt provide an argument There's nothing wrong with using the result of cout's << operator in a conditional statement as you seem to think. All standard streams have a conversion to void* which … | |
Re: >Whats wrong with this class??? It has no point because the standard library already provides an excellent string class. That said, what is it not doing that you want it to? Don't expect us to test and debug your program just because you didn't give us enough information about your … | |
Re: >If someone could write out the necessary code, that would be great! I'm sure it would be, but that's not how it works. You write the code, and we help you with it. Too many people show up expecting us to write everything for them, and that's not the point … | |
Re: fillMe is a copy of the pointer, so you're allocating memory to a copy, then the copy is destroyed, thus destroying your only reference to the memory. This is affectionately called a memory leak. The solution in C is to pass a pointer to the pointer so that you can … | |
Re: >c assigns a negative ASCII value to some symbols No, C assigns a negative [b]integral[/b] value to the variable and the system happens to have a printable representation for that value. It doesn't mean that it's ASCII. >I expect that in your system char == unsigned char. No, if that … | |
Re: Well, what constitutes a number? How about an operator? Determining if the token is a valid operator is simple, just keep a list of valid operator tokens and compare the string. Numbers are harder unless you restrict yourself to the basic integers where the only valid characters are, for example, … | |
Re: >Q.E.D. Yes, but is it correct? The question clearly states "variables" yet your cute little trick will only work on integral types. What about pointers? If a and b are pointers and they point to the same object, you certainly won't get a swap out of this. | |
Re: >int occ = 0; What is occ supposed to do? >if (name[p] == '\0') name wasn't initialized, so this is undefined. There's no need for the array, just take characters as you get them: [code] void readAndCount (int &numWords, int letterCount[]) { char c; do { if ( !cin.get ( … | |
Re: >it says that there arent any errors onvisual studio 2003 .net That's nice, and your point is? I get the same lack of error, but that doesn't make it any less wrong. The only difference between you and me is that I know it's wrong and you're trying to give … | |
Re: Think of a callback as the poor man's polymorphism. By forcing some code, say from a library, to use a well defined and portable interface, clients can supply the interface and change the behavior of the library without touching the library code. A good example is a sorting function. If … | |
Re: What have you done so far besides ask us for help? | |
Re: [quote] please explain in detail how computer work.in term of computer processing cycle.for example when we start compuer how comper parts(ram,processor,hard disk,busses,etc )perform task or work.and how windows work. [/quote] This is a joke, right? Go do your own homework! |
The End.