6,741 Posted Topics
Re: I think your post is in the wrong forum. You mentioned Visual Basic, Javascript, and HTML, yet your post is in the C/C++ forum. | |
Re: >the following three questions You only have two questions. >Any flight can be brought to the front of the queue ready for deleting Since your queue is implemented with a linked list, you can easily splice out an item and replace it elsewhere: [code] void moveToFront ( queue& q, const … | |
Re: >how do i delete the code i put on here You ask a mod to remove selected parts of your post, or the entire post if you feel the need. | |
Re: Please don't post duplicate threads. | |
Re: Okay, and you were expecting someone here to do it for you? From what I can tell by your code, there's been minor (if any) effort on your part to solve the problem. | |
Re: >but how do you accomdate for the letters a-f if the digits are greater than 9? Use a string: [code] static const string hex ( "0123456789ABCDEF" ); [/code] This is a simple problem once you figure it out. The function shouldn't need to be more than 4 or 5 logical … | |
Re: You may like this trick. :) If you treat your records as strings then you can easily place them in a single array and work with them using standard string operations. The cost is two extra characters per element. [code] #include <stdio.h> #include <string.h> #define MAX_ELEMENTS 2 char table[MAX_ELEMENTS][20]; void … | |
Re: The traditional (if inefficient) algorithm is: [code] # Pseudocode gcd ( m, n ) begin while m != n do if m > n m := m - n else n := n - m loop return m end [/code] | |
Re: C++ doesn't have native support for working with monetary values. You need to either find a library that does what you want, or roll your own: [code] #include <iomanip> #include <iostream> #include <sstream> #include <string> using namespace std; string currency ( double value ) { ostringstream sout; sout<< fixed << … | |
Re: Just print array2 for each iteration of the loop. When the user chooses a letter, do a search in array, and if you find it, replace the corresponding index in array2 with the letter. | |
Re: >out<< n; >string s = out.str(); In this case (since you're taking the rightmost digits) arithmetic operations may be easier: [code] if ( n >= 10 ) { // Make sure there are two digits int a = n % 10; int b = ( n / 10 ) % … | |
Re: IIRC you need ten posts before you can create a unique signature. Presently you only have two. | |
Re: >Node *newPtr = new Node ; You're trying to use a constructor with no arguments, yet your Node is declared as: [code] struct Node { Item item; Node *next; Node( Item itm, Node * nxt ) : item(itm), next(nxt) { } }; [/code] Notice how the only constructor declared takes … | |
Re: How about: "We actually have intelligent members and it's fun to post here" | |
Re: Windows is a multi-tasking system, there's no need for TSR's. | |
Re: >if( s=="pass") If we could do this, why would we need strcmp? >gets(s); gets is evil. There's no way to make it safe, so you would do well to forget it even exists. Let's get you started off in the right direction. Unless you're a stubborn C programmer who can't … | |
Re: How much do you want to bet that this will eventually be made due to popular demand for Google Gulp? | |
Re: >while (!file.eof()) While this can be made to work, it requires unnecessary redundancy or an uncommon looping idiom. Anything else is incorrect because eof() only returns true [b]after[/b] an attempt to read from the stream has failed, so the loop will iterate twice for the last record in the file. … | |
Re: >I have no idea what to do here This is where you read a book. If we told you how to solve the problem, or gave you the code to do it, then you would learn nothing. | |
Re: >void printAttitude(int){ When you give a function a body, you [b]must[/b] name each of the parameters: [code] void printAttitude ( int [B]name[/B] ) { [/code] >if (int == 1){ int is a type, 1 is a value. You can't compare types with values. Once you name the function parameter, you … | |
Re: >>which has two int parameters and [B]returns nothing[/B] >if a is larger than b [B]return [/B] a, else [B]return [/B] b Um, no. If a is larger than b you print a, otherwise print b. >p.s i get mixed up with the < and > operators cant remember which one … | |
Re: >Does this ring any bells with you? Of course. It's a common homework exercise and a common part of any business file processing. This is clearly homework, and you haven't shown an attempt, so the help you get will be minimal. | |
Re: Please use [url=http://www.daniweb.com/techtalkforums/misc.php?do=bbcode#code]code tags[/url] when posting any length of code. However, it becomes more important when you post a lot of code. I've added tags to both of your posts, but for further posts it's up to you. | |
Re: >well it needs to be made in a combination of C and c++ really Why? Unless you're familiar with C, the only possible result of trying to mix the two is a lot of compilation and run-time errors. >void main() This is neither C nor C++. main always returns int. | |
Re: >and pass values using set and get functions If possible, set and get member functions should be avoided. The only advantage is that data members can be accessed through a controlled interface, but a well designed class will hide its internals properly, thus making the need for get and set … | |
Re: >if (Date == someDate) Date is a type, someDate is an object of that type. A comparison between them is nonsensical. I assume you want to test the parameter to see if it's the same object as the method is being called on? [code] bool Date::testEqual ( Date& someDate ) … | |
Re: So you have a stack of queues and you want to convert it to a queue of queues? | |
Re: >But I've noticed that after building the project I don't have an .exe in the workspace. Look in the Debug folder. | |
Re: Your teacher is confusing arrays with linked lists. An array is always a contiguous sequence of cells, so there's no need for one cell to "point" to the next. Because the nodes of a linked list are not contiguous in memory, a pointer to the next node is critical. | |
Re: >BUT the program crashed because of the last statement. How did it crash? | |
Re: >1) Do you understand what the idea is for this exercise when reading the task? Yes, they want you to take three integers and pack them into one integer by partitioning a certain number of bits for a value that will never exceed those bits. >2) If so, could you … | |
Re: The most obvious problem is that you're testing for 0 or 1 instead of '0' or '1'. Remember the the contents of your string are characters, not integers. You're also going about the problem in a complicated way, but because you don't want help with that part, I won't show … | |
Re: find returns an index, not a string. For example, if the string is "atest" and you search for "test", find would return 1. Then you could do this: [code] int index = s.find ( "test" ); if ( index != string::npos ) cout<< s.substr ( index ) <<endl; [/code] And … | |
![]() | Re: [url=http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048384015&id=1043284392]This[/url] would be a good start. |
Re: [url=http://docs.sun.com/source/806-3568/ncg_goldberg.html]Clickie Here[/url] | |
Re: [code] int a[10] = {0,1,2,3,4,5,6,7,8,9}; int *p = a; int i; for ( i = 0; i < 10; i++ ) printf ( "%d\n", *p++ ); [/code] | |
Re: Unless your mentor is a total guru (and they're few and far between), you would be better off hanging around an open forum such as this one. That way people who help you can be corrected if they make mistakes, and you won't be pushed unknowingly into bad habits. | |
Re: Search the forum, this has been asked and answered before. | |
Re: A memory leak is simply allocating memory and failing to release it when you're done. Technically, the following illustrates a memory leak: [code] #include <iostream> using namespace std; int main() { int *p = new int; *p = 10; cout<< *p << endl; } [/code] In practice, the operating system … | |
Re: >when do you know it's better to use RECURSION Most of the time, binary search trees are better written with recursive algorithms. Sure, it may be a fun exercise to do them iteratively, but anything but a simple binary search tree will be dreadfully complex without recursion. I haven't met … | |
Re: The difference is subtle. When you declare something, you're simply stating its name and type. When you define something, you're actually creating an object in memory. A declaration doesn't result in memory being allocated, but a definition does. The reason they often look the same is that a definition is … | |
Re: >don't know the name of ',' in English Radix >I don't know how I can do that Floating-point is a bitch to work with. You would be better off converting to a string as vegaseat suggested: [code] #include <iostream> #include <sstream> #include <string> using namespace std; int precision (double val) … | |
Re: >Everything works if i take away the job class So the problem is with job.h and you can focus your debugging there. For example: [code] void getjobnumber() [/code] Don't you think that should be: [code] void job::getjobnumber() [/code] It's also a good idea to tell your compiler to produce preprocessed … | |
Re: >*p=(tree*)malloc(sizeof(tree)); If you really are using C then there's no good reason to cast malloc. It hides the fact that you forgot to include stdlib.h. >void main() main doesn't return void, it never has. It returns int, and nothing else. >fflush(stdin); fflush is only defined for output streams, using it … | |
Re: >can somebody help me finish this please. You've barely done anything. Work out what calculations you want to do on paper before trying the code. That way you have a good idea of what needs to be done. As it is, I get the impression that you have no idea … | |
Re: How do you define the measure of complexity? If the measure is number of features the Ada, PL/I, or C++ would be near the top of the list. What about the ability to describe the same solution in a huge number of ways? Well, at that point my vote might … | |
Re: >how the hell do you do this?! Start by learning from the previous assignment, as this assignment suggests. We don't do homework for you, show an attempt or you'll encounter nothing but stoney silence. | |
Re: [url=http://www.linuxgazette.com/issue77/krishnakumar.html]Start here[/url] |
The End.