6,741 Posted Topics
Re: [QUOTE]I'm new here so please don't be rude.[/QUOTE] I fail to see the logic here. Why would be we rude? Why would your being new change that? Now for the kicker: if you know the answer to both of those questions, you're not so new as to avoid the rudeness … | |
Re: The output is undefined because commas in a function argument list don't act as sequence points. The rule states that if you modify an object, it may be modified only once between sequence points and only accessed to determine the new value. Your printf() statement breaks the latter part of … | |
Re: It looks like you're not confused at all. Please provide some examples of what you don't understand. | |
Re: [QUOTE]how do i compare characters ?[/QUOTE] With the relational operators (ex. [icode]first == last[/icode]). But in your case first and last should be arrays of char, not char. You're using them as strings, after all. | |
Re: [QUOTE]can anyone explain me the functionality and uses of getline()[/QUOTE] No, because there's no standard function called getline() and you didn't specify which library the getline() you're talking about comes from. But even if you did, I suspect the answer will be RTFM. | |
Re: [QUOTE]we apparently also need to use a smattering of Unix and C[/QUOTE] Sounds messy. [QUOTE]Unfortunately, this doesn't really seem to lend itself to a function.[/QUOTE] Why not? You already have the call, ConvertToBase(057,10), which immediately gives you ideas for the function signature: [code] void ConvertToBase(unsigned inputInt, unsigned baseInt); [/code] Your … | |
Re: Um, that's a broad field. You can't think of something where a map of the flow of data is useful? Let me guess, you're a final year CS major. :icon_rolleyes: | |
Re: You can't have executable code outside of a function body. Move those parts to main(): [code] int random_event_number; int main() { srand(time(NULL)); random_event_number = rand() % 100 + 1; .... } [/code] | |
Re: [QUOTE]When this library is loaded by the host application at runtime and this function is called, is the returned pointer pointing to some place in RAM or to the binary file on disk? Is RAM ever involved in this situation other than storing the pointer itself?[/QUOTE] That's heavily dependent on … | |
Re: EOF is a macro defined in <stdio.h>. It's not the value of a keypress, rather it's an "impossible" value returned by various input functions to signal that end-of-file was detected. [QUOTE]Which key corresponds to "end of file" on the keybord??[/QUOTE] That depends on your operating system. On Windows systems the … | |
Re: [QUOTE=gihanbw;1648431]try this. [CODE]printf ("%d\n", EOF);[/CODE][/QUOTE] That's how you find out what the value of EOF is, but it's useless information. The value of EOF doesn't correspond to a key code, and can vary between compilers. | |
Re: [QUOTE]Can you explain me that how i[mpg] can return the same value as mpg[i]?[/QUOTE] Your book already explains it. [ICODE]mgp[i][/ICODE] becomes [ICODE]*(mpg + i)[/ICODE], and because addition is commutative you can change the order of the operands without affecting the result. Thus, [ICODE]i[mpg][/ICODE] is to [ICODE]mpg[i][/ICODE] as [ICODE]*(i + mpg)[/ICODE] … | |
Re: What do you need those functions for? Are you modernizing a virus? ;) | |
Re: [ICODE]list<Event>[/ICODE] and [ICODE]list<Event>::iterator[/ICODE] are not the same type, but printList() expects a reference to T for both parameters. | |
Re: Only admins can change your name, but we're happy to do so if you tell us what you want your new name to be and the new name isn't already being used. | |
Re: [QUOTE]all C programs(I assume C++ too) always have main().[/QUOTE] All C programs have an entry point, and the standard entry point is called main(). [QUOTE]I found it weird because it seems that they were all connected, really contrary to what I know.[/QUOTE] There are essentially two steps for building an … | |
Re: The problem isn't your data type, it's your input method: the >> operator stops reading at whitespace. To read a full line, use getline() instead: [code] string ans1; cout << "How are you? "; getline(cin, ans1); [/code] | |
Re: [QUOTE]Is there any pointer operation involved in this?[/QUOTE] It's hard to answer your question without a code sample of what you're talking about. Please elaborate. | |
Re: Since obj3 is default constructed, you need a default constructor. The default constructor is only provided for you if you don't already have another constructor defined. Adding default arguments to your two argument constructor will have the same effect though. Also, you're trying to send obj3 to cout directly, but … | |
Re: [QUOTE]I am wondering in what kind of situations a programmer would use a union vs using a structure.[/QUOTE] By far the most common use of unions is for variant types: [code] #include <stdio.h> typedef enum { DOUBLE, INTEGER, UNKNOWN } type_t; typedef struct { type_t type; union { double d; … | |
Re: [QUOTE]I think remember hearing someplace that returning in the middle of a method is bad for some reason.[/QUOTE] The "some reason" is it's been argued that having multiple returns from a function makes the function harder to read, reason about, and verify for correctness. It's not a universal opinion; the … | |
Re: You have two issues. First, the condition should be [ICODE]while (temp2 != NULL)[/ICODE] because you want to include the last node in the search. Second, your search loop doesn't update temp2; the loop is infinite. Compare and contrast: [code] while(temp2 != NULL) { if(search == temp2 -> ID) { cout … | |
Re: By the look of main(), insertInDecreasingOrder() is meant to insert a single value into it's sorted position. So there are two steps: [list=1] [*]Find the sorted position of the value [*]Insert the value [/list] Since the vector is assumed to be sorted coming into the function, you can just search … | |
Re: [B]>in the above link they are saying, user should definitely NOT write code of the form[/B] They're wrong. That code (ignoring gets) is best practice. Assuming for a moment that the author of that page isn't an idiot, I'd say there's an implicit assumption about the system/implementation here: [quote] let … | |
Re: [QUOTE]So that I can #define any constants without a limit.[/QUOTE] There's still a limit. For a symbolic constant you're deferring type checking until after preprocessing. The disadvantage of this is that the original source code doesn't match the intermediate code being checked. Any warnings or errors coming from use of … | |
Re: [QUOTE]Your syntax is unfortunately wrong, and is not C++.[/QUOTE] It's C++, just pre-standard C++. [QUOTE]A long time ago, before C++ was standardised, it was just questionable, but now it's wrong.[/QUOTE] Not [i]that[/i] long ago. :icon_rolleyes: Besides, if you look at it without the pre-standard hatred, the only questionable part is … | |
Re: It's contextual, I've seen several different meanings applied to the term. | |
Re: You can write a few non-member friend operators with arguments covering the different cases: [code] class Element { double number; public: Element(double init): number(init) {} friend Element operator+(const Element& lhs, double rhs); friend Element operator+(double lhs, const Element& rhs); friend Element operator+(const Element& lhs, const Element& rhs); }; Element operator+(const … | |
Re: Your question is not an emergency to us, and calling it such will probably be counterproductive. Please don't type in all caps as it makes text harder to read. Finally, to the best of my knowledge, there's no certification in C programming worth doing. | |
Re: How about we start with [i]your[/i] solution? Just because you think it would require too much code, whatever that means, doesn't mean it's not a good solution. | |
Re: [QUOTE]You could use an associative container, such as a map, that has unique key values (in your case integers).[/QUOTE] Unless N is likely to be very large (I wouldn't bet on it), the brute force approach would be simpler and probably more efficient: [code] #include <algorithm> #include <cstdlib> #include <ctime> … | |
Re: What does the file represent? You can certainly break the parts into an array, but a better approach would be to create a record structure with some sort of application-specific abstraction. | |
Re: Remove clrscr, you probably don't need it. | |
Re: [QUOTE=MooGeek;1635641] It's not an algorithm. Algorithm should be: 1. Independent on a programming language. it should be applicable to all programming language. What I did is not applicable to Visual Basic or .Net 2. Should not contain any data types. That means there is no Int or string 3. Does … | |
Re: [URL="http://eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx"]Clicky[/URL]. Pointers are probably "very difficult" not because of any complexity but because you're expecting them to be difficult in your mind. In reality, pointers are both simple and straightforward. | |
Re: >cin and cout are none of those. >They are objects. cin and cout are identifiers referencing objects. | |
Re: I can help with two of your reservations: [list] [*]Objective C is most certainly a unique language. I see it much like C++ in that there's a subset of C, but so robust of an extension to the base that you couldn't compare the two. [*]Objective-C is not limited to … | |
Re: [QUOTE]if you would give me program then it would be my pleasure.[/QUOTE] We don't do that here. We help you write your own code, but that's it. You need to ask specific questions and someone will guide you toward a solution rather than write it for you. So, what's your … | |
Re: Perhaps the book means [I]amortized[/I] O(1) instead of [I]per operation[/I] O(1). Though that's the same for single linked lists, so I can't say why your book makes a distinction. Which book is it? | |
Re: [QUOTE]What can I do to isolate a byte from a uint32_t typedef?[/QUOTE] You can use the bitwise operators to split your 32-bit value into four bytes: [code] uint32_t value; uint8_t bytes[4]; /* ... */ bytes[0] = (value >> 24) & 0xFF; bytes[1] = (value >> 16) & 0xFF; bytes[2] = … | |
Re: [QUOTE]I dont know how to deal with the for loop here [/QUOTE] So don't deal with it. The simplest way to turn recursion into iteration is by expanding the recursion literally using stacks and unconditional jumps. For example: [code] void shell_rec(int t[], int n, int h) { int stack_n[50]; int … | |
Re: The only possible advantage would be if you use the result of search as the first part of deletion when the search returns a matching node: [code] void delete_item(hash_table *htable, T data) { node *match = search_list(htable[hash(data)], data); if (match != NULL) { match->prev->next = match->next; if (match->next != NULL) … | |
Re: I suspect you're simply being overwhelmed by the requirements. It helps to break things down into manageable pieces. For example, you can start by writing code that only reads the file and prints it out. Then that code can be modified to extract individual fields. After extracting the fields, you … | |
Re: [QUOTE]malloc returns the blocks in random way(dynamic) calloc returns the blocks in sequencial way means one after another realloc is used to minimise already allocated memory blocks or maximize the same[/QUOTE] That's the dumbest thing I've read all morning. But it's early, so I'm sure someone will come up with … | |
Re: [QUOTE]Who is Dani in this website?[/QUOTE] Dani's member name is [URL="http://www.daniweb.com/members/cscgal/1"]cscgal[/URL]. [QUOTE]Where are most of the members of this website from? I think most of you are from India, aren't you?[/QUOTE] Members are scattered all over the world. [QUOTE]Why do I see some professional members that have only 1 to … | |
![]() | Re: mvprintw() takes a variable argument list, not a va_list object. A cursory (pun intended) look at the documentation shows that vwprintw() takes a va_list, but doesn't support the coordinates. So your next step would probably be figuring out how to set the coordinates before a call to vwprintw() as that … ![]() |
Re: [QUOTE]I've tried tinkering around with the & pointer with no success.[/QUOTE] That's like saying you're trying to solve a word problem and you've tinkered with the + operator. While it might be relevant, the connection is tenuous and impossible to see from an outsider's perspective. Presumably you're having issues taking … | |
Re: [QUOTE]now that I added more options it's not working and now I'm lost, any expert advice or tips from a second pair of eyes?[/QUOTE] My advice is roll back to something that works and add new options more carefully. For example, add debugging output such as the contents of the … |
The End.