6,741 Posted Topics
Re: >but until i type a word that is not found it display "not found" >but i can search anything because it said "not found" Your loop terminates in one of two ways: A word is found and you use break to jump out early, or a word is not found … | |
Re: There's no timer in C. Presumably you're using a non-standard library, so you'll have to tell us which one so we can read the documentation and then tell you what you want to know (which will probably amount to something like "read the documentation!"). | |
Re: >Is it possible. When it comes to C++, if you ask this question the answer will nearly aways be yes. You can do damn near anything with C++. >If so how may I got the current size of the array. You're reading a C-style string, and C-style strings always end … | |
Re: What operating system? [edit] For rep happy the morons who can't tell the difference, I'm asking if the OP is using Windows or DOS. The answer to the question changes drastically between those two systems, and Borland has written C++ compilers for them both. :icon_rolleyes: ;) [/edit] | |
Re: The cast is bad in C. It hides potential errors such as forgetting to include <stdlib.h> and makes maintenance more difficult if you change the type of the pointer, so you'd best get into the habit of not casting the return value. Pointers are implicitly converted to and from void* … | |
Re: I think you need to get one thing straight when using C++/CLI. When you use gcnew, you're allocating managed memory to a .NET reference. When you use new, you're allocating unmanaged memory to a C++ pointer. I added the pointer part because the syntax is equivalent (pointers use * and … | |
Re: Now what? It's not like you just enlightened everyone with profound insights. This example is trivial and easily obtainable from Google. You aren't answering a direct question and you don't appear to be asking a question either, so why clutter the forum with pointless crap? | |
Re: >how can i consider each cases ? By understanding them. If you don't understand what's going on then you clearly can't tell the computer how to do it. If you [i]do[/i] understand what's going on, you can make such connections as realizing that -25-(-30) is actually the same as -25+30, … | |
Re: At a glance I'd say it's because you're seeking when you don't need to seek, and your position calculations are incorrect. Let's review: >f.seekg(0, ios::beg); >fnew.seekp(0, ios::beg); You just opened these files, they're already at the beginning. >fnew.write(reinterpret_cast<char *>(transferTest), thisSize); >fnew.seekp(testNo*thisSize, ios::beg); When you write to an output stream, it … | |
Re: >The order of operands evaluation (from left to right) is defined >for comma operator, operator && and operator || only... But only the built-in version. When you overload them yourself, you lose the order of evaluation guarantee, which is why it's not recommended that you overload those particular operators. >I … | |
Re: >IOW: cannot be done, which is what I said originally... Then again, "cannot be done" is pretty darn useless as an answer. I imagine alternatives were provided because they come close to the requirement even though it isn't an exact match. Personally, I don't see why there's a need for … | |
Re: >Are you saying I am a spammer? The spam post was deleted, which is yet another reason why I encourage everyone [b]not[/b] to reply to spam because it causes confusion and we usually end up deleting the replies along with the spam to retain continuity. Report it instead. | |
Re: Clearly not, as if we did have one, it would be visible on the forums list. Why don't you try the Java forum? | |
Re: There's no "date" function in C. Be more specific or don't be surprised when nobody answers your question. | |
Re: >why does the syntax of the language gives me two ways to the same thing? Pointers were inherited from C and references were added with C++ to support other C++ features. It's basically the same principle as structs and classes, except pointers and references are actually different in significant ways. | |
Re: Start by searching the forum so you can discover that this question has been asked and answered quite a few times already. | |
Re: If you need to know this, you're probably doing something stupid. Perhaps we can help you improve your program's design if you describe what you're trying to do. | |
Re: This is the tutorial forum, not the help forum. >So if you have more tips then let me know .. Well, [b]actually[/b] trying to write programs with your language of choice works wonders. I notice you didn't mention practice anywhere in that list of things to do. | |
Re: >Do you do the flow chart first or go straight to the code? This question assumes that the only alternative to diving into code is drawing a flow chart. I'm anal about careful design before writing code, but I rarely draw flowcharts unless some management type asks for it. >I … | |
Re: Just make sure you match the expected type. In this case, [ICODE]int *a[][/ICODE] is equivalent to [ICODE]int **a[/ICODE], so I would expect the function to be called something like this: [code=cplusplus] int main() { int **a; // ... fctn ( a, SIZE ); } [/code] | |
Re: >The title is a bit confusing so Ill explain. Unless you didn't say what you meant, I understand your problem perfectly just from the title. Have you tried storing the used random numbers and then searching that list when you need another? A naive solution is pretty obvious and trivial … | |
Re: You don't need fseek to do this, just read the file sequentially using (for example) fgets and look for the substring using strstr. Very simple. | |
Re: >temp = arrayItem; // swap elements >arrayItem = arrayMove; >arrayMove = temp; This won't do jack squat because you're just swapping the pointer values, not the data stored at those addresses. Ignoring the fact that with C++ you should be using templates instead of the much more error prone void* … | |
Re: There's a corresponding direct input function called [URL="http://www.dinkumware.com/manuals/?manual=compleat&page=stdio.html#fread"]fread[/URL]. | |
Re: It's generally a safe bet that the Windows systems you listed will have a C: drive. | |
Re: >I want to put an if statement to make sure that >no letters are entered and only numbers are? You can't control what the user types without delving pretty far into non-standard stuff. You'd essentially need to write your own shell code for handling raw input and the restrict echoing … | |
Re: Perhaps you could explain what you expect your code to do and what it's doing that fails to meet your expectation. | |
Re: >An aggregate class is [...] Also known as a POD (plain old data) type. >how will i fill the items of that array? If you want to initialize it with a list like with the single C object, it's just the nested equivalent (really no different in principle from how … | |
Re: >The time.h header file has some variables as CLK_TCK [...] Note that CLK_TCK is not standard. CLOCKS_PER_SEC is, and on the implementations I'm aware of where CLK_TCK is defined, the two are equivalent. Thus, you should use CLOCKS_PER_SEC. >calling clock() function at two instances and the >difference in time may … | |
Re: >for(int i = 0; i <= 26; i++){ I'd start with this. When you declare an array of 26, it means that the last valid index is 25. This loop runs off the end of the array. >if(ch = alp[i]){ This is a common mistake too. The operator for equality … | |
Re: >The type or namespace name 'MessageBoxButtons' could not be found Are you getting the same error for MessageBox? They're in the same namespace: System.Windows.Forms. | |
Re: >so if you guys can see any legitimate reason not to use _getch() please tell me. I use a compiler that doesn't support conio.h, now what do you suggest, Mr. Smarty Pants? The reason so many people "hate" getch is because it's not a standard function. When you write code … | |
Re: Can you be more specific about what you're trying to do and why? | |
Re: >why is the compiler designed not to accept >any non constant static initialization of types? You can (technically) initialize static data members with non-constant values, just not directly within the class definition: [code=cplusplus] #include <cstdlib> #include <iostream> class foo { public: static int x; }; int foo::x = rand(); int … | |
Re: [url]http://www.cplusplus.com/reference/iostream/istream/get.html[/url] [url]http://www.dinkumware.com/manuals/default.aspx?manual=compleat&page=istream.html#basic_istream::get[/url] | |
Re: You can't call a constructor after the object is created. By the time you get to class2's constructor body, myClass will already have been constructed. However, because class1 doesn't have a default constructor, this won't compile because there's no constructor to call. You can fix it by using an initialization … | |
Re: >If from main i use the commented code then both cout << p and >cout << &p work the same and give me the address of the object >in memory. Thus here 'p' works as a reference to the object. C++ uses operators (and keywords) multiple times and for wildly … | |
Re: Um, what? It sounds like you want to write an interpreter, but your question was so freaking vague I can't be sure. :icon_rolleyes: | |
Re: >Queue q = (Queue)malloc(sizeof(Queue)); malloc always returns a pointer, so the type you're storing the result in must also be a pointer. For future reference, you don't need the cast in C (in fact, it hides potential errors). A much more convenient way to use malloc is: [code=c] /* For … | |
Re: >My question is: "Is array name a pointer (rather a constant pointer)"?? No, but the reality is similar. An array name is converted to a pointer to the first element [I]most of the time[/I]. The official standard terminology is that an array name is converted to a pointer to the … | |
Re: On the top of each page, you can use the Control Panel drop down menu, which has all of the various options for your account. | |
Re: >Which is in higher demand in the job market right now??? Which job market? If you want a job where Java excels, clearly Java will be more in demand. Vice versa with C++. | |
Re: >p_arr[i]=insert; Tell me the value of i in this line of code. | |
Re: >iostream.h is depreceated No, deprecated means that it's still a part of the standard, but not recommended because it may be removed in the next revision. iostream.h was [i]never[/i] a standard C++ header. | |
Re: >Is there any command to know how many lines are there in a text file? No, you read the file and count them either by using line-oriented input or by manually counting newline characters. | |
Re: >cin.ignore(cin.rdbuf()->in_avail()); FYI, this isn't guaranteed to work. A generally accepted solution is to ignore up to the size of the streambuf or until a newline is detected: [code=cplusplus] cin.ignore ( numeric_limits<streamsize>::max(), '\n' ); [/code] | |
Re: >can you please give me an article address which tells when to use stack and when to use heap Oh, if only it were as simple as "use the stack here and use the heap here". :icon_rolleyes:. The problem is that often it's not easy to decide. Generally, a good … | |
Re: What you want is a multi-key search. If the grades match, compare another key. One way is to do it directly. That way you have more control over ascending and descending. For example if you want to sort the grade descending, but the other key (like a name) ascending: [code=cplusplus] … | |
Re: [ICODE]char *argv[][/ICODE] and [ICODE]char **argv[/ICODE] represent the same type, it's just two ways to say the same thing. Think about how [icode]char a[][/icode] turns into [icode]char *a[/icode] and apply the same logic. | |
Re: The first compiler for a language is written using another language, and often the first real test of a new language's usability and power is to bootstrap itself by writing the second compiler in the language itself. A common question is "how was the first compiler created if there were … |
The End.