6,741 Posted Topics
Re: >This is a petition against the live skinning of cats,dogs and other animals in China. Save the animals! But only if they're cute...and domesticated...and not delicious. >Please be aware if you click on the video it is VERY >GRAPHIC - the most disturbing,graphic video ever If it's presented by the … | |
Re: Why use fread at all? fgets seems to be a better fit for your problem, especially since you're using it [i]anyway[/i] to preprocess the record lengths. The more input requests you make, the slower your code will be, so if optimization in your goal, minimize the number of calls that … | |
Re: >I'm betting I'll spot the problem in 3.2 nanoseconds. If it's what I think it is, what makes you think spotting the problem will take that long? ;) | |
Re: >; Index < PlayerName.size() That doesn't make sense at all. You're using the length of the name entered to specify how many names are in the vector? Try [ICODE]Names.size()[/ICODE] instead of [ICODE]PlayerName.size()[/ICODE]. >if ( PlayerName == Names[Index] ) Currently this fails because Index specifies an element that doesn't exist. Your … | |
Re: Wow, um, I'd probably better give you a better example first: [code=cplusplus] #include <string.h> #include <iostream.h> int main() { char line[100]; while ( cin.getline ( line, sizeof line ) ) { char *p = strstr ( line, ".zip" ); if ( p != 0 ) strcpy ( p, ".rar" ); … | |
Re: C++ is case sensitive, and standard names tend to be all lower case. | |
Re: You couldn't even wait a full minute before bumping your thread? :-O Have you tried reading the [url=http://msdn2.microsoft.com/en-us/library/ms724880(VS.85).aspx]reference material[/url] before begging for help? | |
Re: You didn't even ask a question, so how are you expecting to get any help? | |
Re: >NOT USING ARRAYS If you can't use arrays because they haven't been covered, you can't use any of the alternatives, because they're more advanced. Your program is likely impossible with the given restrictions, sorry. | |
Re: >this should work. Please specify what changes you made, and ideally why you made them. | |
Re: If I understand your question correctly, you want to return a reference to one of the structure instances inside your object: [code=cplusplus] #include <iostream> struct block { int data; }; class block_collection { static const int _size = 10; block _base[_size]; public: int get_size() const { return _size; } block& … | |
Re: >Is there a toProper() in C++? No, you have to write it yourself. However, it's not terribly difficult to do: [code=cplusplus] #include <cctype> #include <iostream> #include <string> bool isWordChar ( char c ) { const std::string word_chars = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; return word_chars.find ( c ) != std::string::npos; } std::string toProper … | |
Re: For simplicity sake: [code=cplusplus] #include <fstream> #include <iostream> #include <string> int main() { std::ifstream in ( "myfile" ); if ( in ) { std::string word; while ( in>> word ) std::cout<< word <<'\n'; } } [/code] | |
Re: >No idea why my program keeps crashing. I'd start here: [code=cplusplus] strncpy(word,p1,len); [/code] And I'd start by recognizing that word doesn't point to anywhere meaningful yet. You're trying to write to an uninitialized pointer. | |
Re: The main function has two parameters: argc and argv. The names are irrelevant, as you can change them to be whatever you want, but argc and argv are the most common. argc means [B]arg[/B]ument [B]c[/B]ount, and it's an integer value specifying how many arguments were received. argv means [B]arg[/B]ument [B]v[/B]ector, … | |
Re: >Does anything that I've put jump out as an error I've made? Yes, I see one problem if the vector doesn't already have a size equal to or greater than the size of the array: copy doesn't call push_back, it performs a direct assignment. I'd do something more like this: … | |
Re: >Mabey this function I made will help you You're allowed to use whitespace, you know. That code is pretty nasty with the current formatting. | |
Re: >I have no idea on how the do Not a clue? Can't even form a thought? Seriously, are you so incompetent as to be completely unable to come up with [i]anything[/i]? It doesn't have to be a complete solution, you know. Programmers tend to work incrementally, solving small problems first … | |
Re: 'D' isn't likely to have the value 13. You need to convert the character to a hexadecimal digit value: [code=cplusplus] #include <cctype> // Return [0,15] on success, -1 on failure int hex_value ( unsigned char c ) { if ( std::isxdigit ( c ) ) { // Assume 'A' - … | |
Re: >which doesnt work as a c program its c++ There's nothing wrong with the loop in C99. If you're getting an error about declaring i in the initialization clause, it's likely that you're compiling as C89 rather than C99. In that case you change your loop to this: [code=c] int … | |
Re: >just wondering if there was a way i could make it shorter? Yes, there are plenty of ways. Will they be an improvement? Probably not. The single best way to make your code shorter is to remove redundancy, but at the small length of your program, it's hard to remove … | |
Re: >have relied on Visual Studio C++ 6.0 I'm sorry. I once relied on Visual Studio 6.0 too, and I'm thankful that there are better versions now. >but then the code fails to build!! What a shocker. Speaking of compatibility, did you know that my old installation of Visual Studio 6.0 … | |
Re: >I would like to hear an explanation on why I can't do this. Because you never told p where to point. Thus, it could point anywhere, and "anywhere" is very likely outside of your address space. | |
Re: >Should i use srand() or something? You answered your own question. Yes, you should use srand if you want the sequence to start with a different number each time. Otherwise it always gets seeded to 1, and on your compiler (Visual C++, I'm guessing) the first number generated with a … | |
Re: >Why did you refuse to accept this like a man above you ?... Because a woman with female reproductive organs and a male "identity" is still physically a woman. How is that difficult to understand? [quote=Article] "I opted not to do anything with my reproductive organs because I wanted to … | |
Re: >it is just writing into log entry Is it also writing the ProcessMessage log entries? It looks to me like you'll never get inside the outer if statement in ProcessMessage because you never set _IsStarted to true, and the default value is false. | |
Re: Please tell us what kind of problem you need help with. We can't offer anything more than general advice if you don't specify what's wrong with your code. | |
Re: Use spaces instead of tabs, and this problem will pretty much go away. I know that's not a "real" solution, but it's a workaround until Dani admits that there's a problem. ;) | |
Re: >I do not have any time it is only 2 hours I guess you're learning the lesson of getting your work done on time because nobody is interested in doing it for you. | |
Re: Throw a standard exception. You can find a few in <stdexcept>. | |
Re: The function definition must match the declaration exactly. That means order of parameters as well as type. | |
Re: Perhaps have an option to set the tab stop explicitly in the code tags: (code=c, tab=2) #include <stdio.h> int main ( void ) { puts ( "Hello, world!" ); return 0; } (/code) | |
Re: Hi, do it your damn self. We're not a homework service, but if you actually make an attempt, we'll be happy to help you along a little bit. | |
Re: >when I run it I get a bunch of garbage... I'm not surprised. You assume specific sizes and neglect to take the null character into account when copying. Run your code in a debugger, watch how concat and copy move characters around. You'll quickly see the problem, I'm sure. | |
Re: A segmentation fault is when you access memory that doesn't belong to you. Usually it results from dereferencing a pointer that doesn't point where you expect, or indexing an array out of bounds. | |
Re: >i just dont know what to do about the computer player Start by working out exact steps for how you determine the best move. Codifying those steps puts you a long way toward writing an AI for your game. >What is the best way to end a program Returning from … | |
Re: >if, in your opinion, the destructor i wrote is correct It looks fine to me. >if i need a copy constructor in this program Yes, unless you're okay with two objects aliasing the same tree. Your two options are writing a full copy constructor that clones the tree, or disallowing … | |
Re: UINT is an unsigned (meaning it doesn't hold negative values) integer (meaning it only holds whole numbers) type. The usage is basically the same as "unsigned int". | |
Re: >could any1 tell me how to implement this? Use this hash function until you get the rest of your hash table working: [code=cplusplus] unsigned hash ( int ) { return 0; } [/code] | |
Re: >why is this? Dumb luck. You happened to write to memory that isn't critical to the operation of the program. Therefore, it doesn't crash immediately, only silently corrupts whatever was there. Whether it seems to work or not, you're always taking a huge risk by overflowing your memory. | |
Re: >is it also possible to define 2D arrays? Yes. >how do I pass them into the functions Just like passing any other type, you match the declaration: [code=cplusplus] void foo ( int a[2][5] ); int main() { int a[2][5]; foo ( a ); } [/code] There are variations, of course, … | |
Re: >10. Always wear a belt >2. Do NOT tuck in your shirt (unless at a formal event or when layering) Hmm, always wear a belt but don't tuck in your shirt? Wouldn't that hide the belt for most shirts and negate rule #10? >9. White socks are only worn during … | |
Re: I got one a couple of years ago for, wait for it, Keep It Pleasant. :icon_rolleyes: I was [url=http://www.daniweb.com/forums/post256575.html#post256575]enlightening[/url] a noob on the merits of honesty, and I'm still not sorry. >I just realized Im probably the only person whos gotten an infraction. Ha! If you only knew. We probably … | |
Re: Sorry dude, I haven't worked with 3DS Max for about three major versions. Even then I didn't do much animation. You're better off asking on a forum that specializes in 3D art; Daniweb doesn't really touch on that particular field, so your question is likely to go unanswered. Have you … | |
Re: >My initial question is whether or not should I start with C++ or Assembly? Given only those two options, you'd probably get more out of C++ and have an easier time picking up many of the concepts of modern programming. >I know I probably will end up using Assembly I … | |
Re: >suppose user put const Class as typename T. Then you should respect their wishes, duh. A smart pointer doesn't sound very smart if it doesn't know how to properly point to a const type... | |
Re: It's simple, the friend declarations don't match your function declarations. However, you're hiding that particular error by assuming that using the class' version of T automagically makes the friend declarations template functions. It doesn't, you have to specify that yourself. For example: [code=cplusplus] friend void insertSorted(Node<T> *x, T d); [/code] … | |
Re: What language you use depends on your preferences and the needs of your software. I'd say start with a general purpose language and specialize as you learn more about what you want to do. A good language to start with would be Python. | |
Re: Why not store the information in a file? It's amazingly trivial to serialize objects into XML in .NET, so you might consider that path. |
The End.