143 Posted Topics
I've noticed two strange things with my sound card when it comes to using a microphone. Using multiple microphones, they work, but the result is very very quiet. Also, the plugs are are very loose when seated in the microphone socket. Without going into detailed troubleshooting, has anyone seen these … | |
Re: C++ only natively supports file access through iostreams. You create an object of the *fstream family of classes and open them using a file name and orientation. To open a file for reading you would probably do this: [code] #include <iostream> #include <fstream> #include <string> int main() { std::ifstream file("file"); … | |
Re: You forgot the type: [code] int CommandLineArg::longestDescr=0; [/code] | |
Re: You have to be careful since .dsp and .dsw files are binary if I remember right. That limits you to a container of unsigned char and unformatted binary input: [code] std::vector<unsigned char> v; unsigned char c; std::ifstream s1("doit.dsp", std::ios::binary); while (s1.get(c)) v.push_back(c); [/code] Anything else risks undefined behavior or unwanted … | |
Re: You know, these statements are easier to believe when you can write coherent English and provide objective arguments. You haven't done either, so you can only expect to be treated as a troll. | |
Re: When you don't understand an algorithm, the best way to figure it out is to run it through a debugger step by step, or write down the execution on paper. Of course, if the algorithm is wrong, or the right way to call the function is misunderstood, naturally it will … | |
Re: NORTH, NORTHEAST, SOUTH, and SOUTHEAST are all integral values, probably members of an enum, possibly #define's. The switch is keyed on the getSrcDir() member of path, which returns one of those integral values. It's basically an abstracted version of this: [code] int dir; // ... switch (dir) { case 0: … | |
Re: Can you get a string from one file? If so then can you get a string from more than one file in the same directory? Do you have to search for the files according to some pattern, or do you have a list of filenames? I see this question a … | |
Re: Accelerated C++ by Andrew Koenig and Barbara Moo. The Design and Evolution of C++ and The C++ Programming Language by Bjarne Stroustrup are also books you'll want to have on your shelf if you plan to really learn C++ and not just get through a few classes. :) Note that … | |
Re: Your biggest problem is trying to use stream.read() and stream.write() with a non-POD type. Because the string class is not a trivial class, and your PersonInfo struct has at least one of them, read and write are only guaranteed to cause undefined behavior. You would be better off defining a … | |
Re: [code] int NoLinesIgnored, NoCharsIgnored, NoCharsWanted; std::string s; // ... while (--NoLinesIgnored >= 0) { // Read and discard a line file.ignore(std::numeric_limits<streamsize>::max(), '\n'); } // Read and discard N characters file.ignore(NoCharsIgnored); // Read and save N characters file >> std::setw(NoCharsWanted) >> s; [/code] How you do this will vary depending on … | |
Re: Think recursively. Operands return the value, binary operators perform themselves on the left and right value: [code] if (is_operand()) return value; T a = recurse(left); T b = recurse(right); switch (operator()) { case '+': return a + b; case '-': return a - b; case '*': return a * b; … | |
Re: How does that function not work? There are a few iffy parts, like not checking fopen for success and not considering that fread can return a non-zero failure code, but there are no obvious errors that I can see this early in the morning. ;) | |
Re: When you swap the name array, you'll have to swap all of the other arrays along with it, since each array is a unique object. A good alternative is to stuff everything in an structure and then sort an array of structs: [code] struct record { string name; // ... … | |
Re: You have to do everything that MFC does for you manually. That's a pretty broad topic because "dialog-based application" covers a LOT of stuff. You should consider picking up Charles Petzold's Programming Windows. | |
Re: Fill in the blanks: [code] class Entry { char _name[41]; // +1 for '\0' char _number[7]; // Not including format characters public: Entry(const char *name, const char *number); void reset(const char *name, const char *number); const char *name() const { /* ... */ } const char *number() const { /* … | |
Re: As much as I want to help you, it looks like you want someone else to do your work for you. The code you've provided doesn't even come close to an attempt to solve the problem. It's asking you to write a Dice class that supports rolling the dice and … | |
Re: What have you tried so far, and why is everyone posting C++ questions in the Community Introductions forum? There's a separate C++ forum for such problems. | |
Re: It sounds like the stream isn't getting flushed. That's not correct behavior because calling exit() will flush all output streams with unwritten data. Just for grins, try changing cout to cerr and see what happens. cerr has the unitbuf flag set by default, so it should flush the stream after … | |
Re: >>strcat(msgbuf, (char*)pid); If you have to cast to char * then chances are good you're doing something wrong. ;) What type is pid? I'm guessing it's an int, and that would be a problem because typecasting doesn't make an integer into a string. | |
Re: Your comments are pretty useless for understanding the algorithm. Sure, you may understand the mechanics of each line taken out of context, but do you understand the purpose of each line when taken as a whole for the algorithm? Comments are better for documenting the reasons for doing something, not … | |
Re: Was this what you were trying to do? [code] Activity **p = new Activity*[51]; for ( int i = 1; i <= n; ++i ) { // Read the activity records. pert >> (*(p+i))->i >> (*(p+i))->j >> (*(p+i))->pt >> (*(p+i))->prt >> (*(p+i))->ot; pert.getline((*(p+i))->desc,21); } [/code] | |
Re: If you want to make the class look something like a standard C++ container then Narue's code is about as simple as it gets. You define a data structure that holds items and then define an iterator that controls safe traversal of those items. A simpler, but less safe, linked … | |
Howdy, I'm an IT professional for a seafood distribution corporation. My hobby/obssession is programming with C and C++, so I'll probably hang around there most of the time. The IRC channel is also a cool place, so expect to see me there too. :) | |
Re: I haven't actually written code for fingerprint matching, but I've studied the methods and algorithms and it's pretty complicated. There are a bunch of ways to do it, and I doubt that even if anyone has code not under a non-disclosure agreement, they won't just give it to you. If … | |
Re: You've pretty much checked off everything on the "don't do" list of basic C. Maybe you should start using the standard C++ classes instead of fumbling around with the low level arrays and pointers of the C subset of C++. It's easier to get right if you don't have years … | |
Re: If you defined your operator<< correctly, which seems to be the case, then you don't need to do anything special. That's the nice thing about extending iostreams, you can use them just like you would the standard library stuff: [code] cout << xVal << ' ' << yVal << '\n'; … | |
Re: One good reason would be to hide the implementation. If any changes need to be made to the implementation then it makes sense to separate it into a single file so that any code that uses the header doesn't need to be recompiled. If you place declarations in a header … | |
Re: You never initialize grade to anything. In calculateGrade you assign to grade, but don't do anything else with it, so when the function terminates, all of the work is lost. Then in printResult, you redefine grade, but don't give it a value, so you'll get garbage. | |
Re: This might give you a start for how to define them: [code] #include <iostream> #include <utility> class Integer { int _val; public: Integer(): _val(0) {} Integer(int val): _val(val) {} int get() const { return _val; } Integer operator+=(const Integer& rhs) { return _val += rhs._val; } Integer operator-=(const Integer& rhs) … | |
Re: You're basically just describing the "area of rooms" concept with different terminology. Both can be easily written using multidimensional arrays, or sparse matrices. In the file you could have the x/y/x coordinates that relate to the array indexes followed by location information: [code] 0 0 0 Information about the location … | |
Re: Your best start is by reading the documentation to your compiler. There's no native support for printers in C++, and your compiler probably offers several ways to do it. | |
Re: Can you shrink down your code to something small enough to post? I don't think anyone wants to download your attachment, unzip it, create a collection of source files to match their environment's needs, compile and run your program, then debug it to find the problem. If your program is … | |
Re: >>if ( !isdigit( a ) || !isdigit( b ) ) isdigit takes a single int as its argument, and the int must be in the range of an unsigned char. Both a and b are being passed as pointers to char. Now, since the is* functions from ctype.h are typically … | |
Re: First, make sure that the wireless adapter is working properly and the network connection is enabled and set for DHCP rather than a static IP address. Search for nearby connections to make sure that you can see the wireless access point of the place you're trying to connect to. If … | |
Re: >>So much for Daniweb. Does anyone have at least a better forum I can go to? What do you mean "So much for Daniweb"? Do you have any idea how large and complex an application like this would be? I can guarantee that you won't find a forum out there … | |
Re: I would think that if there's no server, that's a fatal error for the client. Since this is for testing purposes, why bother with an elaborate workaround when you can simply make sure that you run the server first? | |
Re: [QUOTE=dorianoria]Dear guy, I'm looking for information about how to display segy data. However, for your interest, you must know that with perl you could get that information easier. If you are interested, I can send you an extract of the algorithm. Regards, Dorian Oria[/QUOTE] Um, chances are good that if … | |
Re: If I recall correctly, mingw doesn't support curses "out of the box". You can download and install PDcurses from [url]http://pdcurses.sourceforge.net/[/url]. Or if you still want to use getch outside of the curses library, this might work for you: [code] #include <conio.h> /* Or whatever header getch may be defined in … | |
Re: The more protection the better, in my opinon, especially if you're using an "always on" broadband connection, and even more so if you have a static IP. You can set up your router's firewall through the browser interface, usually by opening your web browser and punching in the address of … | |
Re: You can call an external program with the system() function: [code] #include <stdlib.h> system("DIR"); [/code] But that's probably not what you want since you need the output. In that case, you need to create a pipe either through the [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/createpipe.asp]Win32 API[/url], or with a compiler extension if supported. For example, … | |
Re: A much safer way to get an array of strings is with the standard vector and string classes: [code] #include <iostream> #include <string> #include <vector> int main() { std::vector<std::string> a; a.push_back("qwerty"); std::cout<< a[0] <<std::endl; } [/code] | |
Re: >>1, who can tell me the defference between "cerr" and "cout"? cerr is effectively unbuffered, where the stream is flushed after every output operation. cout is not required to do this. >>7/0 is wrong,but I will let the codes continue, that is , let the result of 7/3 output. That's … |
The End.