Forum: C++ Feb 10th, 2008 |
| Replies: 2 Views: 226 Re: Starting C++, any suggestions on compilers? I assume you're after an IDE aswell, or do you intend to use a plain text editor (such as Notepad)? I also assume you're running Windows. If you're running linux, you're already equipped with... |
Forum: C++ Feb 10th, 2008 |
| Replies: 4 Views: 964 Re: Arranging 1D int. array in ascending order. Assuming you're supposed to write your own, rather than use the standard C++ sort function, You'll need to implement a sort algorithm. a bubble sort or a selection sort should be fairly easy to... |
Forum: C++ Feb 9th, 2008 |
| Replies: 6 Views: 749 Re: Non dereferencable iterator C++ it would appear that your plist is empty at the point where your debugger has reached that portion of code.
You might prefer to use the deque::at() function, which is bounds checked, and throws an... |
Forum: C++ Feb 9th, 2008 |
| Replies: 6 Views: 749 Re: Non dereferencable iterator C++ In which case, the message may be telling you that you're attempting to de-reference the end() iterator (Which is actually 'one past the end'). To prevent the overflow problem, you might consider... |
Forum: C++ Feb 9th, 2008 |
| Replies: 6 Views: 749 Re: Non dereferencable iterator C++ The only problem I can see with your code is that eit2 will overflow, being one step in front of eit1 each time. I can't see anything which looks like it should give a compiler error. Could... |
Forum: C++ Jan 8th, 2008 |
| Replies: 3 Views: 640 Re: Memory leaks through stringstream.str() The page appears to be over 10 years old, and the information probably older than that. Standard C++ does not have a class called ostrstream, and, to my knowledge, the standard C++ stringstream... |
Forum: C++ Dec 24th, 2007 |
| Replies: 3 Views: 339 Re: variables naming variables. The alternative, using the <map> library, if you'd prefer to give the orders a 'Key' value identifier
#include <map>
/* ... */
std::map< std::string, order > the_orders;
order... |
Forum: C++ Dec 20th, 2007 |
| Replies: 13 Views: 1,138 Re: Timing Execution I think he asked for 250 miliseconds didn't he? not 25?
Anyway, it shouldn't matter, because there's no guarantee that CLOCKS_PER_SEC is equal to 1000 (I believe on POSIX systems its defined as... |
Forum: C++ Dec 19th, 2007 |
| Replies: 14 Views: 1,411 Re: convert variable to ASCII number main returns an int because the standard says it returns an int. if you omit the int return type from main then some compilers will complain and not compile at all, others might allow it to compile... |
Forum: C++ Dec 18th, 2007 |
| Replies: 10 Views: 560 Re: int * Help I think he means 'Dynamic Memory Allocation' - I could be wrong though. Either way, it works fine with both char and int |
Forum: C++ Dec 18th, 2007 |
| Replies: 12 Views: 615 |
Forum: C++ Dec 16th, 2007 |
| Replies: 3 Views: 646 Re: Compare in templatized data structure Additional:
It seems I was half-right, although, the STL uses the std::less<T> functor class as its default predicate for sorted containers, as found in the <functional> header. (std::less in... |
Forum: C++ Dec 16th, 2007 |
| Replies: 3 Views: 646 Re: Compare in templatized data structure I could be mistaken, though I believe that the STL sorted containers expect a type with a valid operator<. If the type doesn't provide one, then overloaded constructor(s) will take an additional... |
Forum: C++ Dec 15th, 2007 |
| Replies: 12 Views: 628 Re: Templates -- Need major help please!! The best tip I can think of with regard to writing templated code, is to write a non-template version first. Then you can be sure that your program is correct for one type (such as int), and that... |
Forum: C++ Dec 8th, 2007 |
| Replies: 2 Views: 1,336 Re: Capitalize first letter of word If you're able to split each 'word' into separate strings, then you're already half way there
use the toupper function on the first character of that word, to generate the uppercase equivalent of... |
Forum: C++ Dec 7th, 2007 |
| Replies: 3 Views: 528 Re: Isspace counting The >> operator skips over whitespace automatically.
One alternative could be to capture each line of input from the file individually as a string, using the getline function.
std::string... |
Forum: C++ Dec 6th, 2007 |
| Replies: 3 Views: 506 Re: Algorithms There's no such thing as a "Best" sorting algorithm. Depending on the amount of data you're holding, and how ordered the data is to start with, one algorithm may be better than the other in... |
Forum: C++ Nov 6th, 2007 |
| Replies: 7 Views: 632 Re: Candidate Program That appears to be almost every Computer Science student in the world these days - How fewer posts would this place get if students had 'more confidence'? ;) |
Forum: C++ Sep 5th, 2007 |
| Replies: 13 Views: 1,400 |
Forum: C++ Sep 5th, 2007 |
| Replies: 38 Views: 1,746 Re: passing arrays / updating object arrays a[7] is an element in your array
(Also - if your array is only 7 elements in size, then valid elements are indexed 0-6, so you're accessing one-past-the-end.)
try this instead
pizza.set ( x , y ,... |
Forum: C++ Sep 3rd, 2007 |
| Replies: 8 Views: 1,182 Re: for rookie C++ (template) programmers I understand your frustration.. there's still one or two pages in the book Modern C++ Design that frankly leave my head aching when I try to work out what the examples are actually doing
Yes, the... |
Forum: C++ Sep 3rd, 2007 |
| Replies: 8 Views: 1,182 Re: for rookie C++ (template) programmers its a rather elaborate complicated example of template metaprogramming for a newbie IMHO. Try this as a simpler one :)
template<int N>
struct factorial
{
enum { value = N *... |
Forum: C Sep 1st, 2007 |
| Replies: 7 Views: 590 Re: Check windows passwords Ah ok, sorry I misunderstood the original post - I thought you were after something that would allow reading the contents of the windows password files. |
Forum: C++ Aug 31st, 2007 |
| Replies: 5 Views: 1,133 Re: difference between pointers and handles AFAIK the C and C++ languages don't define the term 'handle', so its use can vary according to context.
In addition to the usage as described in Hamrick's link, some texts use 'handle' to describe... |
Forum: C Aug 30th, 2007 |
| Replies: 7 Views: 590 Re: Check windows passwords That would probably be a password cracker's dream come true. Seriously, do you really think there's going to be an easy way to access encrypted Windows passwords like that?
(I am aware of programs... |
Forum: C++ Aug 29th, 2007 |
| Replies: 7 Views: 743 Re: binary code Representing integers as a binary number..? if not, would you be a bit more specific?
Here's one way, using a bitset
#include <iostream>
#include <bitset>
int main()
{
//bitset with 8 bits
... |
Forum: C++ Aug 28th, 2007 |
| Replies: 22 Views: 1,320 Re: school's back, and so am i :D Yes that's right, but it assumes you're rotating about the origin :) Either way, the origin is a point, so, as hamrick said, you need two points in order to rotate something. :) |
Forum: C Aug 27th, 2007 |
| Replies: 16 Views: 821 Re: Displaying Average There's no point having an array of one character..
and there's no point storing seperate variables for each grade, you could just do this (note the single-quote marks)
if (studentgrade > 90)
... |
Forum: C++ Aug 27th, 2007 |
| Replies: 18 Views: 986 Re: Help with Linked Lists I think what you're seeing is a memory leak, the data isn't being deleted, its just being lost in the wilderness..
I assume that lst is the pointer to the head of your list (?), so don't modify that... |
Forum: C++ Aug 27th, 2007 |
| Replies: 16 Views: 1,726 Re: How to clear a string Are you talking about C++ strings or C-style char arrays? (I assume you're talking about char arrays, based on your post)
What do you mean by "completely empty"?
You can make a C++ string blank by... |
Forum: C++ Aug 27th, 2007 |
| Replies: 15 Views: 1,556 |
Forum: C++ Aug 27th, 2007 |
| Replies: 10 Views: 960 Re: Numbers That depends, this isn't really a programming question, but more of a discrete/pure mathematics one - How comfortable are you with numbers in bases other than 10? - particularly binary (Base 2),... |
Forum: C++ Aug 26th, 2007 |
| Replies: 10 Views: 960 Re: Numbers Maybe i'm unclear of the question.. but a number is just a number - you can use it to represent whatever you want. There's nothing particulary special about your 32 bit max value.. some systems... |
Forum: C++ Aug 26th, 2007 |
| Replies: 2 Views: 1,337 Re: How to create a notepad in c++? You'll need to explore a graphical API to create the GUI - this will depend what platform you're running
(Or you could explore a cross-platform API such as wxWidgets http://www.wxwidgets.org/ ) |
Forum: C++ Aug 25th, 2007 |
| Replies: 18 Views: 986 Re: Help with Linked Lists Yes, it would be similar, except instead of looking for an element by checking its data, you'd be looking for an element based on its position. so you'll need a counter (A for-loop may be more... |
Forum: C Aug 24th, 2007 |
| Replies: 7 Views: 630 |
Forum: C++ Aug 24th, 2007 |
| Replies: 18 Views: 986 Re: Help with Linked Lists your line number will be the position in the list, so you probably want to implement a function which will iterate through the list 'N' number of times to return a pointer to the element you want (or... |
Forum: C++ Aug 23rd, 2007 |
| Replies: 1 Views: 208 |
Forum: C++ Aug 23rd, 2007 |
| Replies: 8 Views: 671 |
Forum: C++ Aug 23rd, 2007 |
| Replies: 12 Views: 1,665 |