- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 80
- Posts with Upvotes
- 69
- Upvoting Members
- 35
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Re: Your code is difficult to read - try adding some formatting! a few points to note 1) Why is there a semicolon before int main() ? Presumably its supposed to belong to the function prototype 2 lines up - you should put it there instead, else it just looks like … | |
Re: One of the biggest problems with C++ books older than 1999/2000 is that they do not recognise alot of modern Standard C++ content. A problem commonly found with "revised" books after 1999/2000 (Books which were originally published long before C++ was standardised, but have been updated) is that the Standard … | |
Re: I wouldn't call 2 a special case - it fits the general description perfectly; [I]A number evenly divisible only by 1 and itself.[/I] :) | |
Re: That's a totally nonsensical question, what are you trying to do? Machine code is the very low-level instruction set that your computer's processor uses. Are you looking to learn how to program in an assembly language? | |
Re: In general, the steps to getting MSVC++ 2005 to work should be something along the lines of - Create a new Solution, using a Win32 Console Project - Right-Click on the project's name in the solution explorer, choose properties. - In the Configuration Properties Window, look for the option to … | |
Re: [QUOTE=Ancient Dragon]Using Microsoft compilers, I am not at all convinced that std::cout is faster than printf(). I have made similar tests in the past on other computers with M$ os and have never seen one where cout is faster than printf(). And I would be supprised if *nix computers was … | |
Re: You can't in standard C++ [url]http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.20[/url] [url]http://www.cprogramming.com/faq/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385[/url] | |
Re: Tell your school that you are unhappy about being taught using obsolete technology. Turbo C++ has no place in today's world, and insist that they provide you with an education which is relevent - i.e. by teaching you using modern material which works on modern compilers. | |
| |
Re: Also, I would consider any code which attempted to automatically delete anything from my machine (whether it were browser history or otherwise) without my permission as malicious code. Your intentions may not be malicious, but you should seriously think about how users of your website are going to react. You'll … | |
Re: fgetc is a C function. The C++ way to do it is [CODE=cpp]char ch = std::cin.get() [/CODE] | |
Re: The [icode]>>[/icode] operator is whitespace delimited by default when used with any kind of stream; including cin, fstream and stringstream; so you can use that to your advantage to turn a stringstream into a simple tokeniser e.g. [code=cpp]#include <string> #include <sstream> #include <iostream> [/CODE] ... [CODE=cpp]std::istringstream hello("the cat sat on … | |
Re: It's a little bit vague, but I think it depends exactly on what your code currently does and how much those objects have got in common (more importantly, how much your initialisation code has got in common) Are you currently implementing this using a lot of repeated code? If so, … | |
Re: Short Answer: No. Long Answer... You only need to [b]delete[/b] something if - You created the object using [b]new[/b] (or you used some other library or function which created it with [b]new[/b]) - You own the object (i.e. it is not owned by a smart pointer or another class from … | |
Re: Here, you have declared a variable called [icode]ptr[/icode] [QUOTE=faraz ahmad;1762882][code] void question1() { int i=0; int* ptr=nullptr; [/code][/quote] Here you are declaring a completely different variable, which also happens to be called [icode]ptr[/icode] and hides the variable you'd previously declared by the same name.[QUOTE=faraz ahmad;1762882][CODE] while(boolean!=false) { cout << "Enter … | |
Re: [QUOTE=personathome;1762325] it either puts out c or some random number. Also I can not use isdigit unfort. [/quote] [CODE] char c = ch; if(c>=48&&c<=57) cout << 'c' << endl; [/CODE]A character inside single-quotes denotes a character value, so all you're doing here is printing out 'c'. This value has absolutely … | |
Re: [QUOTE=kikic;1762284]I must not use finite function like that you write me,I need to write function step by step which works for alphabetic sorting in C++...[/QUOTE] Ancient Dragon's other suggestion was to do a google search for [i]Bubble Sort[/i] - try that and you will get plenty of good links which … | |
Re: You're misunderstanding somewhat. It is not possible to simply resize a 'raw' array (Whether it is created by [b]new[/b] or as an ordinary array object). Once an array is created in memory, it can't be extended - The reason being that you have no control over the layout of objects … | |
Re: [QUOTE=gampalu]This program works... I don´t know if it's like this that youi want: //snip[/QUOTE] Most probably not! choose a language, either C or C++, and stick to it.. mixing the two like that is really a very very bad idea. | |
Re: operator<<() is a member function - you can only pass one parameter at a time to your Stack object using operator<<() - eg, [CODE]Stack myStackObj; myStackObj << SomeValueHere;[/CODE] If you are merely trying to overload operator<<() then it should be a non-member function. When defined as a member, the object … | |
Re: That depends what the program is. I doubt that he's asking you to rewrite the sqrt, log and pow functions from math.h (Unless your course is a mathematics one). if you post a description of your problem, and the code from your current solution, there might be another way to … | |
Re: Are you asking for reviews? I don't own the book, but I am aware of its existance, and its outdated approach to teaching the language. C++ primer plus is an old book which was "updated" after C++ was revamped and standardised; unfortunately, when C++ was reborn as a new language, … | |
This code snippet outlines a simple, no-frills linked list. Tested under MSVC++ 2003 and Comeau, but not guaranteed bug free. Snippet includes example main() . This snippet is intended as an example of a possible implementation of a linked list class (Of which there are many variations) For a better … | |
Re: Mainly because of an observation by Edsger Dijkstra in 1968, where he argued "GOTO Statement Considered Harmful" (Google it and you'll find copies of the white paper) In brief, the observation is that (In general), the number of 'goto' statements a programmer uses in their code is inversely proportional to … | |
Re: if [inlinecode]Node[/inlinecode] is a template class, then the way to create an object is to specify the type you want inbetween < and > [CODE=cpp]Node<int> my_int_Node; Node<double> my_double_Node; Node<bool> my_bool_Node; //etc. [/CODE] | |
Re: First of all, I suggest taking a look at the short tutorial on random numbers here - [url]http://www.daniweb.com/tutorials/tutorial1769.html[/url] | |
Re: Bearing in mind that if this is a console application, there's a finite number of characters for any given line which you can output without the code spilling over to the next line, and completely ruining your formatting anyway. Therefore, it may be simplest to put in an upper limit … | |
Re: These aren't examples of quines though - To qualify as a quine, the program must be able to replicate its own source code [U]without[/U] any input (either from a file, the keyboard, or anywhere else) see here for a little more info [url]http://en.wikipedia.org/wiki/Quine_%28computing%29[/url] | |
Re: I don't know how many others do this, but I've often found myself drafting replies to problems which people have posted, but not actually sending my reply straight away. On many occasions, i've kept the reply in a notepad document, and ended up deleting them, if I think i'm wrong. … | |
Re: [QUOTE=Narue;464574] It strikes me that your problem is confidence, and the best way to build confidence is to jump right in. Do something, anything, even if it turns out to be wrong. As it is you'll spend all of your time second guessing yourself and then you'll come to us … |