6,741 Posted Topics
Re: Show us what you've tried. Clearly you know how to open a file and read words from it (more or less), so what's wrong with declaring an array of strings and filling it up with the words from a file? [code=c] char keywords[100][100]; FILE *in = fopen ( "keywords", "r" … | |
Re: >What would be a good book for C++ starters? In order of usefulness as you learn C++: [B]Accelerated C++[/B] by Koenig and Moo will get you started (beginner). [B]The C++ Programming Language[/B] by Stroustrup will keep you going for quite a while (intermediate). [B]The C++ standard[/B] will blow you away … | |
Re: >is there any showFile() type of function in libraries?? No, you have to write it yourself. | |
Re: >Thanks For what? It looks like you posted your assignment in the hope that someone will do it all for you. Why don't you try it yourself and when you have some proof of effort and a real question, we'll help you. | |
Re: Subtract myvector.begin() from endpoint and you'll know the size of the vector after calling unique. | |
Re: >This seems like a bad idea.. Yea, that's a really bad idea. >So should I redesign the class? No, this is a common problem and there's a common solution. Make the destructor pure virtual, but you still have to give it a body unless you want all of the child … | |
Re: >Any other suggestions ? Can you send me a list of them? I collect programming books, so I may buy some of them off of you. | |
Re: Remove all of the parameters. It looks like you're actually expecting the global variables to be the ones that are changed, but when you use function parameters with the same name, they hide the global variables. When the function returns, you haven't changed the global variables at all. | |
Re: When working with linked data structures, the best thing you can do is take out a piece of paper and draw the logic. Don't draw what you think is happening, draw exactly what your code does, and you'll find the bugs. | |
Re: >#include<stdlib.h> To be strictly correct, this should be <cstdlib>. >void main(){ main returns int. >i don't know how to make the number be between 0 and 100 only [ICODE]rand() % 100[/ICODE] is the easiest way, and it should suffice for basic pseudorandom numbers. >the computer always choose the same random … | |
Re: At this point you're not working with multiple bytes, so the only way to split up the value is to shift away the least significant digit. | |
Re: >What i want to do is delete all the shapes in >the group box where the result was wrong. Maintain a list of pointers to shape objects that are added to the group box. Then when you want to delete all of the shapes in the group box, it's as … | |
Re: >What is outtextxy? It's a function from BGI's graphics.h library that writes a string to the screen at specific x,y coordinates. >how do i do outtextxy to a int?? You have to convert the int to a string first. Search the forum, there are plenty of threads on that particular … | |
Re: >I'm looking to beable to add the date and time in secs Seconds from when? You'd be better off formatting the date and time, then using that string rather than trying to get some non-portable numeric formatting: [code=c] #include <stdio.h> #include <time.h> int main ( void ) { char buffer[1024]; … | |
Re: >is there a way to convert a char[2] = '1', '2' kinda thing to an int ? Yes. It's easiest to store the characters as a string first though, so that you can take advantage of standard solutions without resorting to something manual. A good solution is using strtol to … | |
Re: >DayOff = (Days) x; This is a C-style type cast. It's taking the value of x and attempting to coerce it into the Days type. You should avoid casting whenever possible, because types aren't always interchangeable, and especially in this case you can get in over your head very quickly. … | |
Re: Passing by value is better described as pass by copy. A copy of the value is made and sent to a function. This means that if you change the value in the function, the original remains the same: [code=cplusplus] #include <iostream> void foo ( int copy ) { std::cout<<"In foo … | |
Re: >Points PointA(); That's not an object declaration, it's parsed as a function declaration (a function called PointA that takes no arguments and returns a Point object by value). Remove the parens: [code=cplusplus] Points PointA; [/code] | |
Re: Sleep from windows.h also takes milliseconds, not seconds. Your call would change to [ICODE]Sleep(5000)[/ICODE]. | |
Re: The easiest solution is to use redirection straight from the command string: [code=cplusplus] std::system ( "dir > test.txt" ); [/code] | |
Re: puts is used for printing strings, not integers. Change [ICODE]puts( j[i]);[/ICODE] to [ICODE]printf("%d\n", j[i]);[/ICODE] and it should work better. | |
Re: >I want to throw the exception, the user will see the msg, press return and then terminate. Set your own custom termination handler. Look in your reference for the <exception> header to get more details. | |
Re: Moved to a more appropriate forum. | |
Re: Try flushing the stream after the file is printed. cout isn't tied to your file stream, so a read isn't going to force a flush, and I'm willing to bet that the file isn't large enough to fill the stream buffer: [code=cplusplus] temp.close(); cout.flush(); getch(); [/code] | |
Re: >You should not ever call main( ) from within you program, >that essentially restarts a new instance of the program! No, it essentially doesn't compile. C++ doesn't allow recursive calls to main. | |
Re: >Wow 0.o huge right Eh, I've seen worse. >What language are you using? Well, C++ [i]does[/i] support those alternative tokens. C does as well if you include <iso646.h>. >Oh my god! Why not initialize this way: >char board[ROWS][COLUMNS] = {'.'}; Probably because that wouldn't work. It only initializes the first … | |
Re: Use a string instead: [code=cplusplus] #include <iostream> #include <string> using namespace std; int main() { string op; cout << "enter test "; cin >> op; if(op == "test") cout << "test sucessful\n"; else cout << "w00t\n"; } [/code] | |
Re: >Can i initialize char arrays using preamble initialization ? That's the first time I've heard that term, but I'll assume you're asking if you can use strcpy_s in the way you've attempted. Since you received an error, I'm wondering why you're even asking the question because it's obviously not allowed. … | |
Re: >Should I understand that he is an admin/staff writer? Davey is happygeek, the second admin aside from Dani. | |
Re: >can anyone tell me why ? swapNode doesn't do anything. When you want to change a value, you pass a pointer to that value, right? [code=c] /* Changing the original objects that a and b point to */ void swap ( int *a, int *b ) { int save = … | |
Re: This is C++, so I'll answer your question in the C++ forum and close this thread. | |
Re: >I'm just stating a point. Sorry, I missed the point. Can you explain it to me? | |
Re: The message is pretty clear about what's wrong. You say that insertNumber returns an integer value, but you fail to return a value with a return statement: [code=java] return 0; // Or some other number [/code] | |
Re: >My question is do I have to add all the include files to the command line? You don't add headers (include files) on the command line. They're strictly for the compiler so that it has declarations for the names that will be linked in later. What you're doing is telling … | |
Re: >If you have any difficulty in understanding(at a quick glance that is!) Most of your comments are pointless. At a glance I can tell what the code is doing; any reasonably experienced programmer can do this easily. What I really want to know is [I]why[/I] you're doing it. I can't … | |
Re: >Something should really be done about that, as I'm sure if that were >an actual post, a warning would be issued from Admin at the very least. Good idea. Reputation comments do fall under Daniweb's policies, so anyone who feels a comment was out of line can report it, and … | |
Re: >warning C4013: 'strlen' undefined; assuming extern returning int Make sure to add [ICODE]#include <string.h>[/ICODE] to your code. | |
Re: >what does it this mean Initialize the array so that the first 25 >components are equal to the square of the index variable ? I would assume something like this: [code=cplusplus] for ( int i = 0; i < 25; i++ ) alpha[i] = i * i; [/code] | |
Re: >Have you ever cheated on a test/exam? Yes, but I was considerably better at it than you seem to be. ;) | |
Re: >It looks like he's declaring variables, but there is no type. He is declaring a variable, and the type of the variable is [ICODE]enum Days[/ICODE]. DayOff is an instance of the Days enumeration. >In line 11, what does days(x) mean? As an example, Days(1) is the same thing as Monday. … | |
Re: >can u tell me how to change the color of the background and text ? There's no standard way to do it, but because you seem to be using a Windows compiler, I'd say [url=http://msdn2.microsoft.com/en-us/library/ms686047.aspx]this[/url] is your best bet. >#include<stdio> Remove this, you're not using anything from stdio. Also, it's … | |
Re: I personally have a problem with downloading mysterious attachments. It would be more considerate of you to post a bare bones example of your program that exhibits the problem you want help with. | |
Re: apvector isn't supported directly by Visual Studio. Do you have the actual header, or are you getting an error that it can't be opened (because it doesn't exist)? | |
Re: >Can any one explain what exactly happens when there >is a buffer over flow and how does it affect malloc. No, because that's an implementation detail. It depends on how malloc works for your system as well as what you're doing in your code. Post your code that fails (preferably … | |
Re: >However, I am sure you can complicate this question up to a great extent. Yea, like "oh wait, I'm not using Windows!". ;) | |
Re: >You are talking GUI programming No, PlaySound isn't a GUI function, but it does require linking with a new library. >can anyone help to show the problem You need to link with winmm.lib. IIRC you can go to the Project menu, select Project Options, then in the box titled "Object … | |
Re: >can anyone help in developing a code 4 msking a telephone directory using class? Can you be any more specific? >is der ny1 2 help me?hw can i c th rply 4 ma questns? Not if you keep typing like your keyboard is broken. Full sentence English with an attempt … | |
Re: >Please use some code indenting to make it more readable. For example: [code=cplusplus] #include <iostream> #include <conio.h> using namespace std; int main() { int x, y; while ( true ) { cout<<"Please Enter a positive number\n"; cin>> x; if ( 0 != x || 1 != x ) break; cout<<"Please … |
The End.