6,741 Posted Topics

Member Avatar for Tenjune

[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 …

Member Avatar for Narue
0
97
Member Avatar for hackit

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 …

Member Avatar for Narue
0
154
Member Avatar for devanshee

It looks like you're not confused at all. Please provide some examples of what you don't understand.

Member Avatar for Narue
0
2K
Member Avatar for UrbanBourbon

[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.

Member Avatar for Narue
0
2K
Member Avatar for geeksforgeek

[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.

Member Avatar for D.M.
0
144
Member Avatar for shaunchu

[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 …

Member Avatar for cse.avinash
0
114
Member Avatar for abc88

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:

Member Avatar for Narue
0
75
Member Avatar for Triarius

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]

Member Avatar for Narue
0
230
Member Avatar for N1GHTS

[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 …

Member Avatar for N1GHTS
0
152
Member Avatar for Rupindersingh
Re: EOF

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 …

Member Avatar for Rupindersingh
0
121
Member Avatar for Rupindersingh

[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.

Member Avatar for Narue
0
246
Member Avatar for king03

[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] …

Member Avatar for Ancient Dragon
0
138
Member Avatar for cent91
Member Avatar for cent91
0
330
Member Avatar for wajiha irfan
Member Avatar for Narue
0
54
Member Avatar for coolbeanbob

[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.

Member Avatar for coolbeanbob
0
444
Member Avatar for Vongola_Takeshi

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.

Member Avatar for Vongola_Takeshi
0
98
Member Avatar for asrockw7

[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 …

Member Avatar for Moschops
0
163
Member Avatar for mcconnell_34

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]

Member Avatar for Narue
0
181
Member Avatar for challarao

[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.

Member Avatar for challarao
0
145
Member Avatar for Rass Saee
Member Avatar for NoUserNameHere

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 …

Member Avatar for NoUserNameHere
0
145
Member Avatar for Jamblaster

[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; …

Member Avatar for rubberman
0
493
Member Avatar for bondo

[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 …

Member Avatar for Narue
0
194
Member Avatar for anonadre

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 …

Member Avatar for anonadre
0
129
Member Avatar for vergil1983

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 …

Member Avatar for Narue
0
305
Member Avatar for urbangeek

[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 …

Member Avatar for Narue
0
2K
Member Avatar for geeta_11

[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 …

Member Avatar for Narue
0
104
Member Avatar for tyu1996

[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 …

Member Avatar for cse.avinash
0
194
Member Avatar for MooGeek
Member Avatar for MooGeek
0
258
Member Avatar for fruitymo

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 …

Member Avatar for fruitymo
0
197
Member Avatar for indru

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.

Member Avatar for Narue
-1
234
Member Avatar for Um num num

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.

Member Avatar for ProgrammingGeek
0
158
Member Avatar for PaulProgramer

[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> …

Member Avatar for PaulProgramer
0
222
Member Avatar for Steven_gerrard

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.

Member Avatar for raptr_dflo
0
162
Member Avatar for saurabh_s
Member Avatar for MooGeek

[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 …

Member Avatar for reactivated
0
383
Member Avatar for hackit

[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.

Member Avatar for cse.avinash
0
164
Member Avatar for himanjim

>cin and cout are none of those. >They are objects. cin and cout are identifiers referencing objects.

Member Avatar for Ancient Dragon
0
160
Member Avatar for Dani

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 …

Member Avatar for jbennet
0
466
Member Avatar for susees

[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 …

Member Avatar for raptr_dflo
0
1K
Member Avatar for starkk

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?

Member Avatar for raptr_dflo
0
106
Member Avatar for NerdyChick27

[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] = …

Member Avatar for Narue
0
379
Member Avatar for now how abt tht

[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 …

Member Avatar for Adak
0
508
Member Avatar for starkk

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) …

Member Avatar for tajendra
0
149
Member Avatar for catalin4

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 …

Member Avatar for Narue
0
135
Member Avatar for rohoni

[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 …

Member Avatar for Narue
0
1K
Member Avatar for Hani1991

[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 …

Member Avatar for MooGeek
3
403
Member Avatar for Mouche

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 …

Member Avatar for Mouche
0
184
Member Avatar for Celcion

[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 …

Member Avatar for Greywolf333
0
116
Member Avatar for garu525

[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 …

Member Avatar for garu525
0
168

The End.