6,741 Posted Topics
Re: >there's no way to either go to the top of the page The Home key on my keyboard is sufficient for that task. | |
Re: >I declare a pointer ptr (int *ptr; ) and then define ptr >as 5 by saying *ptr=5; what adress is ptr pointing at The precise answer depends on where you've declared the pointer, but the short answer is "nowhere you can dereference". Therefore your code exhibits undefined behavior. A pointer … | |
Re: Stop attaching short programs, please. It's better to embed the code in your post when you can and attach only when the code is far too long to be put in a post. | |
| |
Re: *Puts on old school Narue hat* >Can ne1 help No, you're beyond help. If you had done even a simple search, you would have found approximately a metric shitload of posts asking exactly the same question and getting a complete answer for any variation of cluelessness you might be able … | |
Re: You need to define num as well as declare it: [code=cplusplus] class number{ private: static int num; public: int getnum() {return num;} void setnum(int innum) {num=innum;} }; int number::num; [/code] | |
Re: >_TCHAR* tmp = new _TCHAR( i+1 ); This looks like a bug to me. You want to simulate a dynamic array, but you're using the wrong syntax: [code=cplusplus] _TCHAR* tmp = new _TCHAR[i + 1]; [/code] | |
Re: >vectors are like the peanut butter to my chocolate! Which suggests that you go out of your way to use vectors even when they're not the best solution. Next! | |
Re: >i am unsure how to find words only starting with f and replacing the string. You might find it easier to work through the source string character by character. This is really the realm of regular expressions, but an algorithm for matching the first character of each word isn't difficult: … | |
Re: >But how to do it? Did you not read the answers you've been given? Both of them told you to use the strstr function. | |
Re: More code please. Preferably a complete program that exhibits the problem so we can play with it. | |
Re: Perhaps you should try to learn about trees in general. Most people start with [URL="http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]linked lists[/URL] to get a feel for how linked data structures work, then they move on to [URL="http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_bst1.aspx"]binary search trees[/URL], and then to graphs. Generally if you understand binary search trees, it's not a great leap … | |
Re: >argv is the argument vector >argc is the number of arguments Note that argc and argv are simply conventional names. You can change them. In fact, I see av and ac quite a bit as alternate names. >Argument vector is an array of pointers to strings. It's an array of … | |
Re: >for (o=n; o>0; o--) Each row of the second triangle is based on n, and n doesn't change throughout your program. I believe you want to set o to m instead. | |
Re: There's a sticky [URL="http://www.daniweb.com/forums/thread90228.html"]How do I flush the input stream?[/URL] that explains your problem and provides several solutions. Thanks for searching before posting...not! :icon_rolleyes: | |
Re: Must you people dredge up four year old threads? | |
Re: >how did the linker or compiler find the path to that IO library when all i do is only header inclusion? Compiling and linking are two separate stages. The header is [I]only[/I] relevant during compilation because declarations for the names you use must be present before you use them or … | |
Re: Both functions are broken in quite a few ways >const comma=','; C++ doesn't support implicit int. >char *accum=""; There are two serious problems here. First, you're not allowed to modify the contents of a string literal, but that's precisely what you're trying to do. Second, a pointer doesn't imply infinite … | |
Re: In my experience you save yourself a lot of headaches by avoiding both sharing (working with the same file through two streams simultaneously) and read-write access (being able to read from and write to the file through a single stream). | |
Re: >how it is logical to get this to work? C++ takes an expression and evaluates it in a boolean context, but the expression itself doesn't have to evaluate to the bool type. [ICODE]a = 0[/ICODE] evaluates to the value of a, which is 0, which when treated in a boolean … | |
Re: Be more specific please. I have a vague idea of what you're asking only because I've answered the diamond question several hundred times already. | |
Re: >it doesn't stop on 13 Clearly not, because you don't tell it to stop when the user enters "13". Both loops run exactly 13 times, and they'll do this without fail unless you break from the loop: [code=c] for ( i = 0; i < 13; i++ ) { /* … | |
Re: >A much clearer method would be rand()%x , where x is the number you want. Clearer, but not necessarily better. rand has subtleties that need to be considered. In particular, there are two distinct problems with rand: one historical and one that is still common. The historical problem is that … | |
Re: Good luck with your search. | |
Re: >What is the usage of Static functions and where we can use static functions have a visibility restricted to the translation unit in which they're declared. You can use them anywhere a regular function can be used, but you [i]should[/i] use them everywhere you can because they follow the rule … | |
Re: >vector<T> :: iterator ptr; Change this to: [code=cplusplus] typename vector<T> :: iterator ptr; [/code] Dependent types need explicit qualification with typename because C++ assumes they're not types and they can't be used in a declaration. | |
Re: The entered character is always of a char type. Presumably what you want is to see if that char represents a digit: [code=cplusplus] #include <cctype> #include <iostream> int main() { char ch; while ( std::cin.get ( ch ) ) std::cout<< std::boolalpha << (bool)std::isdigit ( ch ) <<'\n'; } [/code] | |
Re: >but this is just one node No, it's just the definition of a node. You don't actually have any yet. >please tell me how i can code a BST in c++ ? [url=http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_bst1.aspx]This[/url] is in C, but you look like you're at the point where it doesn't matter, because you … | |
Re: I think it's easier to use an array instead of a switch: [code=cplusplus] int days_in_month ( int month, int year ) { int month_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int days = month_days[month - 1]; if ( month == 2 && is_leap … | |
Re: Be more specific. Formatted text with fprintf is right aligned by default, so clearly you want to do something other than that. | |
Re: You're in luck. If you don't initialize all of the items in your array in the initialization list, the ones you didn't specify will be set to the equivalent of 0 for that type: [code=cplusplus] double U[N]={0}; // Completely filled with 0 double g[N][M]={0}; // Completely filled with 0 [/code] | |
Re: >template<class Tpl, unsigned int iSize> >void AddData(CClient& c, CArray<Tpl,MAX_SIZE>& ar) Change MAX_SIZE to iSize. Since you didn't have iSize anywhere in the parameter list or as an explicit list in the instantiation, your compiler couldn't figure out what it was supposed to be. | |
Re: Post your code. This is an exam, not just homework, so we're going to be even more anal than usual about [I]you[/I] doing the work. | |
Re: Start by including the <string> header, which you failed to do. Also note that NULL isn't a compatible type with std::string; your stack class makes unwarranted assumptions about the type of T. Instead of NULL, you can generally use T() safely as a default value, though it's usually a better … | |
Re: >and regardless of user admin guest or normal user... This is a suspicious clause. A benign program would be comfortable simply accepting expected restrictions for installation tasks that require elevated privileges. Presumably you know how to set your program as one of the startup applications when those restrictions are in … | |
Re: >1. In C++, how can we print "Hello World" say 100 times witout >using any loops (for, while/do while, for_each or recursion)? You can't. Sorry. Often questions like this (given out by clueless teachers) have a loophole in the wording where you can use recursion or an unconventional loop with … | |
Re: >string a; This is an empty string. >a[i]= tmp; a[i] doesn't exist. a is still an empty string. The subscript operator does not change the size of a collection. | |
Re: >Hey guys. Just a question. >Is it possible to [...] The answer to any "Is it possible?" question is invariably "Yes!". Further, many of these questions can be answered with simple experimentation. So are you just lazy or what? | |
Re: You can't copy an istream object, pass a reference instead: [code=cplusplus] int wCount(ifstream& myFile); [/code] | |
Re: >i wouldbe greatful if somebody could give me a solution to this... We don't give freebies, but I'll point you in the right direction: [code=cplusplus] #include <cctype> #include <iostream> #include <string> int main() { std::string line; std::cout<<"Enter your a line of text: "; if ( getline ( std::cin, line ) … | |
Re: It's generally considered impolite to throw around non-universal acronyms without defining them. | |
Re: [url]http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html[/url] | |
Re: >quickSort(befList, needSwap(*itr,*itr2)); >quickSort(aftList, needSwap(*itr3,*itr)); You're not supposed to call needSwap here, just pass the pointer as you did in main: [code=cplusplus] quickSort(befList, needSwap); quickSort(aftList, needSwap); [/code] >But I can't figure out exactly how I'm supposed to call it. When you actually need to call needSwap, you can do so in … | |
Re: >I can cout the string literal by just stating the >name of the object or I can use the data function. Yes to the first part, no to the second. You can "cout the string" by passing just the string object, but it's not safe using the data member function … | |
Re: Start by seeing if the system function will do what you want. | |
Re: >hoping someone can throw more light into this It's quite simple on the surface. Your code is broken. ;) The long answer is that there's no intervening sequence point between the evaluation of function arguments, so you're invoking undefined behavior by modifying x multiple times between sequence points. Both of … | |
Re: If you don't mean the logical OR operator in C, example follows, then you need to be more specific about what exactly you want to do. [code=c] #include <stdio.h> int main ( void ) { if ( 0 || 1 ) /* || is the logical OR operator */ puts … | |
Re: >Anyone considerinstalling Vista -- don't. You will have nothing but headaches. I've only had one problem with Vista, and it wasn't caused by Vista. But I fixed that particular issue (with my graphics card driver) and now everything is just peachy. >I say try it out first, off a friend … |
The End.