6,741 Posted Topics
Re: [QUOTE]Please advise.[/QUOTE] You're compiling as C++. Compile as C instead and the error will go away, but the code is still slightly off in terms of modern correctness. This is more correct: [code] #include <stdio.h> /* Full prototype (file scope is conventional) */ int add_two_numbers(int a, int b); /* Full … | |
Re: The differences between languages of the same ancestry (C++ and Pascal are both Algol derivatives) are more syntax than anything, and those differences are easy to figure out. Further, knowing C++ will help you even if you ultimately never use it, so continuing that education is certainly reasonable. But you … | |
Re: [QUOTE]Why would absolute beginner, that does not know how to use rand(), use vectors?[/QUOTE] What's wrong with vectors? I assume you're suggesting that arrays be used instead, which is silly. C++ doesn't [I]have[/I] to be learned from the bottom up. In fact, learning C++ with an eye toward realistic code … | |
Re: [QUOTE]Now, an affecting factor is that there may be anywhere from no strings with the same length in the vector up to all strings having the same length.[/QUOTE] Obviously the best case for comparison is where no strings have the same length, in which case the comparison is O(1) because … | |
Re: And? What have you done so far? Realize that Daniweb isn't a homework service, we expect you to put forth a certain measure of effort. | |
Re: Maybe I can get my iOS developer friends to hang out on Daniweb now. ;) | |
Re: And the problem you're having is what, exactly? | |
Re: I see no headers included. Presumably you've been relying on the precompiled header stdafx.h that Visual C++ likes to put into projects? | |
Re: Appendix C is what you want from [URL="http://www.intel.com/content/dam/doc/manual/64-ia-32-architectures-optimization-manual.pdf"]this manual[/URL]. However, note that due to differences in processors and the myriad optimizations (multi-core, pipelining, etc...), pinning down reasonably exact counts in real code is very difficult without extensive profiling. | |
Re: That's a pretty evil looking expression. Here's a hint: the two trailing -'s combine to form a postfix decrement operator while the two leading -'s are separate unary operators. | |
Re: dayDifference() returns an int value in all cases. Since you didn't specify what that value is, it's garbage. | |
Re: [QUOTE]Right now I have a snippet of code that makes logical sense but in fact doesn't work[/QUOTE] Actually, that snippet makes no sense at all. If you're looking to write a bigint library, then your best bet would be to find a simple one and study the code. A good … | |
Re: The string class is in namespace std too. In fact, every standard name is in the std namespace. | |
Re: On a side note, code tags are pointless if your code has no formatting. Please indent your code. | |
Re: [QUOTE]But what happened to operator precedence?[/QUOTE] Your parentheses aren't changing anything, the precedence of [ICODE](i=15)||(j=26)[/ICODE] is identical to [ICODE]i=15||j=26[/ICODE]. Short circuiting rules here, so if [ICODE]i=15[/ICODE] evaluates to true, the latter half of the expression is skipped. | |
Re: [QUOTE]can anyone explain me how to use the inline function in c++ code with example?[/QUOTE] There are two ways, actually. The inline keyword is one: [code] // foo is explicitly inline inline void foo() { /* ... */ } [/code] Another is for member functions defined inside of a class: … | |
Re: [QUOTE=c++creator;1638381]Thanks Saith and Cross213,though what does Cross213 mean by?[/QUOTE] He means (I hope) that the prototype introduces enough information about a function to safely call it without requiring the function's definition to be visible. | |
Re: [QUOTE]And you can't say cin >> k without asking for it to be entered.[/QUOTE] This is false. Just because there's no prompt doesn't mean the program isn't waiting for input. [QUOTE]I've tried compiling your program and it just gives a blank screen so that should mean something. [/QUOTE] It means … | |
Re: [QUOTE]I thought it was mandatory because the examples in the book are done this way.[/QUOTE] You should probably get a newer book. In the example from your first post, removeEntry() [i]is[/i] declared prior to main(). A function definition also acts as a declaration. | |
Re: There are a number of graphics libraries available depending on your needs. Can you be more specific? | |
Re: That sounds like the focus of your windows is changing. Is Ctrl+F9 running the debugger? What IDE are you using? | |
Re: Look for details on the System::Net::Mail::SmtpClient class. It's dead easy to send email with .NET. | |
Re: [QUOTE]You can thank global warming for all but the earthquake.[/QUOTE] That's a lie! Global warming is responsible for earthquakes too. Along with (but not exclusive to) excessive cold weather, blizzards, ice storms, volcanos, meteors, tsunami, AIDS, cancer, Alzheimer's, the common cold, homosexuality, missing socks, spelling errors, Barack Obama, fizz overflow … | |
Re: How many variables do you have named "pi"? | |
Re: A forum on the C++ language isn't likely to be informative either. You'd have more luck on a forum that specializes in CURL. | |
Re: Yea, that's quite enough. Stupid abbreviations are annoying enough, but they're also against our rules: "Do post in full-sentence English" "Do not write in all uppercase or use "leet", "txt" or "chatroom" speak" Thread closed. Please collect your thoughts and compose a coherent question before posting again. kthxbye. | |
Re: sirknieghf, you need to learn how local variables work: [code] void foo() { info customer; // An info object is created customer.price = 123; // The info object is modified } // The info object is destroyed [/code] All of your functions are treating the customer object as if it's … | |
Re: I don't think you're ready for pointers and strings just yet. You still don't have a handle on variables. Please take a step back and take a little more time on simpler programs. But since I don't want this post to be completely negative, here's correct code for your program … | |
Re: [QUOTE=Adak;1630037]printf returns the number of chars printed, and you didn't print any objects, so it would return a negative number, as an error IF your compiler allowed it to compile.[/QUOTE] printf() only returns a negative value if there's an "output or encoding error". Since printf()'s internal loop is essentially skipped … | |
Re: [QUOTE]Too late, already made char array tokens[/QUOTE] It's never too late to refactor your code into something better. | |
Re: Your pause at the end isn't really pausing because there's extraneous characters in the stream. Specifically, when reading an integer, the [noparse][Enter][/noparse] key you pressed will remain in the stream for [ICODE]cin.get()[/ICODE] to read later. You'll find that if you call [ICODE]cin.get()[/ICODE] a second time, it'll work as intended, which … | |
Re: [QUOTE]why removed the & sign in the name?[/QUOTE] The following is a common oversimplification: "Always use & on variables in scanf()". While the intention is fine--don't confuse beginners by introducing pointers too soon--but the simplification is likely to cause just as much confusion. The reality is that because scanf() writes … | |
Re: [QUOTE=shanki himanshu;1637804]recursion is calling a function itself and in a function we have set of statements. does this means it is iteration??[/QUOTE] Do you think it's a basic question [I]now[/I]? Muahahahaha!!! :D Let's make it simple: [B]Iteration[/B] is an [i]explicit loop[/i] using one of C's loop constructs (for, while, do..while[1]). … | |
Re: [QUOTE]What is the difference between "G1" and "G1 "[/QUOTE] A space at the end... | |
Re: [QUOTE]Actually my compiler ( Dev c++) do not support code without conio.h , getch().[/QUOTE] Unless you typed "without" while meaning "with", that's total bullshit. If you did mean "with", it's still incorrect because Dev-C++ does support conio.h to a small extent, though [URL="http://www.bloodshed.net/dev/faq.html#conio"]a little tweaking[/URL] is required. | |
Re: What have you tried? We're not going to give anything away unless you put forth some effort first. | |
Re: The error is coming from your linker. This suggests that double_linked.cpp isn't being linked to main.cpp. How are you compiling this, and what does your main.cpp look like? | |
Re: [QUOTE]Q1. What is your name and job profile (like Database Administrator, Programmer etc.)?[/QUOTE] List me as anonymous. My job profile is software architect (enclosing all parts of development from requirements gathering to deployment and maintenance). I also act as a consultant for IT and development staff in a wide range … | |
Re: [QUOTE]the point of linked lists is to make swapping elements efficient[/QUOTE] Any linked data structure has that benefit, but it's not the point of linked lists[1]. I'd argue that the point of a linked list is the principle benefit, which would be efficient growth (ie. insertion and deletion) in the … | |
Re: [QUOTE]WHY IS THE VALUE OF THE VARIABLE first getting modified??[/QUOTE] You have too many variables named [ICODE]first[/ICODE], and it's confusing you. In particular, you have a global [ICODE]first[/ICODE] and a local [ICODE]first[/ICODE] which hides the global one. Compare and contrast with my version of your program: [code] #include <stdio.h> #include … | |
Re: [URL="http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]Clicky[/URL]. | |
Re: [QUOTE]In c++ we use <iostram.h> but not in c.[/QUOTE] [i]You[/i] might, but since many modern compilers fail to accept <iostream.h> at all, a lot of us prefer the standard <iostream>. [QUOTE]C++ reduces the length of code by using object.[/QUOTE] Reduced code size isn't one of the advantages of OOP in … | |
Re: It looks like you have a vector of pairs, which is slightly harder to use with std::accumulate() because you need a custom function or function object to handle the summation: [code] #include <algorithm> #include <iostream> #include <utility> #include <string> #include <vector> struct sum_second { template <typename T, typename U> U … | |
Re: [QUOTE]IS THERE ANY WAY FOR THE USER TO ENTER "ENTER" TO FINISH TYPING....[/QUOTE] Since you're using getche() to read characters, your loop needs to recognize the first part of a newline. Since you're using Windows, that character would be the first part of a CRLF sequence: '\r'. [code] #include <iostream> … | |
Re: [QUOTE]the point is the code that I posted gives an error why?[/QUOTE] Because your code is wrong. [QUOTE]and somtimes the other exp gives an error...[/QUOTE] Because your code is wrong. [QUOTE]is it compiler dependent?[/QUOTE] No, your code is just wrong. Read [url=http://pw1.netcom.com/~tjensen/ptr/pointers.htm]this[/url] and [url=http://eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx]this[/url]. | |
Re: [QUOTE]While the second method using fprintf() seems to work.[/QUOTE] fprintf() and fwrite() do completely different things. fprintf() converts values into their textual representation while fwrite() just dumps the bytes of the value to a stream without any kind of conversion. Your garbage is perfectly understandable as the contents of the … | |
Re: [QUOTE]I was there right now, and there were only a couple of ops in other than me. Very very quiet.[/QUOTE] Because a weekday morning should be hopping. ;) | |
Re: [QUOTE]Search a lot but didnt got the same[/QUOTE] Very rarely will you find a solution to your exact problem. Since you haven't done any threaded development thus far, I'd recommend a [URL="http://www.codeproject.com/KB/threads/ThreadingDotNet.aspx"]general threading tutorial[/URL] first, then something [URL="http://www.codeproject.com/KB/threads/StepByStepThreads.aspx"]specific to your current problem[/URL] of updating the UI with progressive results from … | |
Re: I'm not a fan of the Deitel series, but you'd be wise to get the newest edition (8th edition, at the time of this post). It'll contain error corrections from the other editions as well as reasonably up-to-date content. Though every time I check, the Deitel books are hideously overpriced. … | |
Re: Those requirements are odd. Given the ranges of [ICODE]ti[/ICODE] and [ICODE]k[/ICODE], I would expect to check if [ICODE]ti[/ICODE] evenly divides [ICODE]k[/ICODE], not if [ICODE]ti[/ICODE] is divisible by [ICODE]k[/ICODE]. Any [ICODE]k[/ICODE] larger than 109 in the latter case is completely predictable and need not be checked. |
The End.