6,741 Posted Topics

Member Avatar for shaider6192

Closes? I'd more expect it to hang since the first loop of the combination calculator is infinite. Though it's quite likely the undefined behavior of overflowing your data types causes a crash. Can you describe what happens when the program "closes"?

Member Avatar for shaider6192
0
86
Member Avatar for daviddoria

How about two wrappers with implicit conversions? [code] class Radian { double value; public: Radian ( double init ): value ( init ) {} operator double() { return value; } }; class Degree { double value; public: Degree ( double init ): value ( init ) {} operator double() { …

Member Avatar for Narue
0
109
Member Avatar for #define

[B]>what is the reason that int, float,char,double, >bool are of 4,4,1,8,1 byte respectively in C++?[/B] Perhaps if you explain why you think those values are wrong, we can offer enlightenment. [B]>are arrays built in?[/B] Do you need to include a header? No? They might just be "built in" then. [B]>128 …

Member Avatar for Narue
0
110
Member Avatar for shaider6192

At the risk of confusing you, I'll offer a more robust solution than you'd normally be given. Since it's more complex, I'll happily explain anything you don't understand: [code] #include <stdio.h> #include <string.h> int continue_working ( const char *msg, const char *true_case ) { char buffer[BUFSIZ]; /* Don't do printf(msg); …

Member Avatar for Narue
0
309
Member Avatar for Izarian

[B]>what they do have is an unsigned char class to >convert ints/doubles/floats to binary/bytes.[/B] You're thinking of type punning, I believe. Tricky business that stuff, not usually a good idea in C++. [B]>if you have an unsigned char*, you can't actually get >the size of the number of bytes this …

Member Avatar for Salem
0
280
Member Avatar for vidyabhat

[B]>how to find the no. of characters which are in a file in c program[/B] Open the file and count them. Though I suspect you're asking the wrong question. Most of the time this question comes up when somebody wants to allocate a buffer large enough to hold the entire …

Member Avatar for Narue
-2
72
Member Avatar for shaider6192

[B]>can someone help me get the codes for this program..[/B] I'm sure somebody hates you enough to stunt your growth by giving you code. The whole point of assignments like this is to make you practice solving problems and translating those solutions into code. So try it yourself first, then …

Member Avatar for shaider6192
0
137
Member Avatar for InnocentVamp

I'm not sure I understand what you're asking. It sounds a bit like you want to create an abstract data type but don't know how. If that's the case, you can check out the libraries offered [URL="http://www.eternallyconfuzzled.com/jsw_home.aspx"]here[/URL] for one such method. The data structures are a bit more complex than …

Member Avatar for Narue
0
172
Member Avatar for iammfa

String literals use double quotes, character literals use single quotes. My guess is that you need to come to terms with the fact that [ICODE]char[/ICODE] is not a string type, then look at the std::string class.

Member Avatar for WaltP
0
228
Member Avatar for blueman:-0

[B]>Yea, looking at your code makes my brain hurt.[/B] If you're not exaggerating then you should probably do something about that weak mind. Maybe take up sudoku. ;)

Member Avatar for mrnutty
0
184
Member Avatar for XxWARGASMxX

strcat expects a valid C-style string (ie. an array of char terminated by '\0'). In your case, you failed to meet the requirement that the array is terminated by '\0', so you've invoked undefined behavior. This should help: [code] char *cdisp; cdisp = new char[200]; // Add the following line …

Member Avatar for Narue
0
82
Member Avatar for toleen

[B]>this might b helpfut for you[/B] Perhaps if your program is the only one running on the machine. A busy loop like the one in your [ICODE]wait[/ICODE] function is a terrible CPU hog. Seeing as how the OP's program really only does two trivial things once per second (print the …

Member Avatar for Narue
0
153
Member Avatar for vino chithra

[B]>is cyclic hashing possible??[/B] Yes, though as described it looks like you're trying to independently invent [URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_hashtable.aspx#openaddr"]linear probing[/URL].

Member Avatar for Narue
0
78
Member Avatar for sailee

>Pls help me in finding hcf and lcm of 2 nos It's easy. All you do is grab the igm, do a qp on the xt half of the pgid and roll everything up into a qt7-qualified czsm. Hope that helps! :)

Member Avatar for hk<3ob1993
0
195
Member Avatar for jrkeller27

[url=http://eternallyconfuzzled.com/jsw_home.aspx]This[/url] covers several different trees, including a variation of the heap. I haven't yet gotten around to finishing my splay tree tutorial, but here's a draft of the code (for both top down and bottom up splaying): [code=c] #include <stdio.h> #include <stdlib.h> #include <time.h> struct jsw_node { int data; struct …

Member Avatar for amromun
0
192
Member Avatar for sutty8303

>I/O ops defined in STD namespace .... I/O manipulators are deined in iomanip They're all in the std namespace. The streams and manipulators without arguments are declared in iostream, manipulators that take arguments are declared in iomanip. So to use setw and the like, you need to include iomanip, but …

Member Avatar for peter_budo
0
306
Member Avatar for ShawnCplus

[B]>I doubt it'll stem the flow of begging or spoonfeeding - which >is becoming a growing problem - but it wouldn't hurt.[/B] IMO, all of those announcements and stickies are completely ineffective for fixing the problem. All they do is make it easier for mods to justify punitive action.

Member Avatar for almostbob
0
403
Member Avatar for BevoX

>Is it possible to create your own data type? Not a class, or a >structure, that builds from predefined C++ types, but your very own. What do you think a class is supposed to be? It's a user-defined type. What you seem to want is magic: a magic type that …

Member Avatar for maf5693
0
4K
Member Avatar for jonnybgood

Every C++ test I've seen online has been lame. You'd be better off asking us for tough questions and collecting them into your own test.

Member Avatar for Narue
0
118
Member Avatar for Lukezzz

[B]>Is it true that the finally block doesn´t execute either ?[/B] The finally block always executes, whether an exception was thrown or not.

Member Avatar for Lukezzz
0
133
Member Avatar for makan007

[B]>Is this correct?[/B] Give it a try, the code to test this function is trivial.

Member Avatar for problemkid
0
468
Member Avatar for chaienbungbu

[B]>I see the "new" operator is very different from java one, is it right?[/B] Not especially. The Java new expression creates an object of the specified type, calls the specified constructor, and returns a reference to the object. This is pretty much identical to C++ where a new expression creates …

Member Avatar for chaienbungbu
0
180
Member Avatar for Aamit

strcpy is for C-style strings, not C++ string objects. >How to solve it?? Change that line to this: [code=cplusplus] t_time = hr_str; [/code]

Member Avatar for Ancient Dragon
0
3K
Member Avatar for johnson9000

>// I think there should be a return but my compiler doesn't give me an error Just because your compiler doesn't complain doesn't mean that there's no error.

Member Avatar for Dave Sinkula
0
160
Member Avatar for ArtphotoasiA

[B]>I can reconsider my personal opinion on the big G policy if they will close to >Chinese government request also if this mean close the business in China.[/B] You should send them an email. I'm sure that changing your personal opinion is a huge incentive for Google.

Member Avatar for vaultdweller123
-1
146
Member Avatar for neoeinstein

[B]>I still don't understand why I need to use namespace[/B] Because the standard library places everything in the std namespace. If you want to use the standard library, you have no choice but to at least mention that namespace somewhere in your code. [B]>What happens if I don't use it?[/B] …

Member Avatar for neoeinstein
4
683
Member Avatar for 006ruler

[B]>when i ran this program, it said that it was unable to open the file.[/B] The file probably isn't where ifstream is looking. Try calling perror to see if it gives you more information.

Member Avatar for cpeister
0
165
Member Avatar for clutchkiller

[B]>a constructor for a class is only used to initialize variables[/B] What about a shared resource manager that puts a lock on the resource in the constructor and unlocks it in the destructor? The constructor may or may not initialize data members, but also does other work.

Member Avatar for Narue
0
85
Member Avatar for jakesee

[B]>But what is the difference here?[/B] [ICODE](&FileParser::saveElement)[/ICODE] is parsed as the address of a class member. The parentheses are redundant in this case. [ICODE]&(FileParser::saveElement)[/ICODE] is parsed as trying to access a static member and then take the address of it. [ICODE]saveElement[/ICODE] isn't a static member, and if it were a …

Member Avatar for Narue
0
95
Member Avatar for dtvonly

Did you try putting the text file in the same place as the exe on your desktop?

Member Avatar for sknake
0
118
Member Avatar for rwill357

[B]>It works the problem is I would like to ensure I'm meeting the professors intent.[/B] I can't claim to know what your professor intended, but I'd say you're on the right track.

Member Avatar for program_helm
0
128
Member Avatar for m7md.is

[B]>In standard C++ you can't. If your compiler is one of those that has enhancements, >there may be a way, but it's non-standard and therefore not recommended.[/B] I can only assume you were running on autopilot and didn't proofread your post, because that's just stupid. If there's a standard alternative, …

Member Avatar for m7md.is
0
224
Member Avatar for King Dede

[B]>I am trying to find the best cmplier for the C++ program.[/B] If one compiler were the best, there wouldn't be so many out there, would there? :icon_rolleyes: The trick is to try out a bunch of them and pick the one you like best.

Member Avatar for Stefano Mtangoo
0
324
Member Avatar for PhiberOptik
Member Avatar for PhiberOptik
0
122
Member Avatar for iamcreasy

[B]>Can anyone tell me why?[/B] Your pointer is uninitialized. It's not a pointer to infinite memory, it's an [i]invalid[/i] pointer. Expect crashes and unpredictable results, because that's what happens with undefined behavior. [B]>I wanted to take a line input of infinite length.[/B] It's not that easy. You need to read …

Member Avatar for xavier666
0
147
Member Avatar for dubeyprateek

>How does compiler impliments intializer lits? It depends on the compiler. >How intializer lits improve performence? There are two steps when you initialize in the body of a constructor. The first step is performed before the body, where the data members are allocated memory and given a default value. The …

Member Avatar for NaveenGowdar
0
216
Member Avatar for wellibedamned

[B]>i tried a somewhat natural approach, which seems to have failed..[/B] Completely understandable. However, the rule that an array name becomes a pointer to the first element only applies to the first dimension. So your function should be declared as one of the following: [code] // Pointer to an array …

Member Avatar for mrnutty
0
160
Member Avatar for grealish234

[B]>'isnum' : cannot convert parameter 1 from 'float' to 'const char *'[/B] Why yes, a float is indeed not the same as a string. You can take input as a string rather than a float to correct the problem. Alternatively you can convert the float to a string, in which …

Member Avatar for mrnutty
2
114
Member Avatar for baken33

[B]>Can you help me please ?[/B] Not until you show us your attempt and prove that you're not a cheating leech.

Member Avatar for Nick Evan
-3
148
Member Avatar for vaibhav2614

[ICODE]w[/ICODE] and [ICODE]w->word[/ICODE] are two separate pointers that (as you say) were allocated using two separate calls to the memory manager. Therefore, the code you posted is correct. Make sure you don't call [ICODE]free(w->word)[/ICODE] in a loop, or in two different places.

Member Avatar for Narue
0
111
Member Avatar for tzushky

I get the impression that you're looking for a variant type. C isn't good at that, so you might consider something more along these lines: [code] #include <stdio.h> #define TYPEA 0 #define TYPEB 1 struct my_struct { int type; void *data; }; struct a { double x; }; struct b …

Member Avatar for Narue
0
185
Member Avatar for V0ldemort

LPCWSTR is a wide string type, but std::string is a narrow string type. You need to decide which one you really want to use and either switch to std::wstring, or turn off Unicode for your application so that the Win32 functions don't use the wide versions.

Member Avatar for V0ldemort
0
190
Member Avatar for sonisuhas

[B]>how does the ramdomize function works?? >does it have some formulae to bring out its output?[/B] [URL="http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_rand.aspx"]This random number tutorial[/URL] might help. [B]>Computers can't generate random numbers the way our mind does[/B] Our minds are exceptionally bad at coming up with random numbers. If you grab anyone off of the …

Member Avatar for Narue
0
137
Member Avatar for avirag

[B]>Or loop through the 'char' and use the num = (num * 10) + char process.[/B] Nine times out of ten, this algorithm breaks on edge cases. Unless it's a homework problem, such a manual process isn't recommended when there are better alternatives like std::stringstream. [B]>Use something like this[/B] Manually …

Member Avatar for Narue
0
2K
Member Avatar for lola_fcis

Hmm, I think [URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_bst1.aspx"]this[/URL] might be a good read for you.

Member Avatar for Narue
0
79
Member Avatar for __kanth

[B]>2) when the person enters his password it should not be visible.[/B] You need a way of reading raw input without echo. The most well known function that does this is getch, from <conio.h>, but I can't recommend that because I don't know what compiler you're using. You can search …

Member Avatar for __kanth
0
188
Member Avatar for nerdinator

[B]>How to make a time based regular function? >Like something that plays a sound every 1 second?[/B] To what end? If all you want to do is hog the process and play a sound every second, it's a trivial matter: [code] #include <iostream> #include <windows.h> void kindadumb() { for ( …

Member Avatar for Salem
0
119
Member Avatar for luliana
Re: Q

[B]>Q[/B] Really? I'm surprised you took the time to hold down the shift key if you were too lazy to come up with any kind of useful title. [B]>I wanna ask about virtual function.. why we use it & when?[/B] You make a member function virtual when you want to …

Member Avatar for Narue
-2
74
Member Avatar for ahmed supari

This is where you write a test program to find out for yourself: [code] #include <stdio.h> int main ( void ) { const char *s = "test"; const char *t = "temp"; do printf ( "s: %c\tt: %c\n", *s, *t ); while ( *s++ == *t++ ); return 0; } …

Member Avatar for Narue
0
173
Member Avatar for wheelie

[B]>Am am I right in thinking it has something to do with external linkage?[/B] Something like that. The following operators are implicitly declared in every file: [code] void *operator new ( size_t bytes ); void *operator new[] ( size_t bytes ); void operator delete ( void* ); void operator delete[] …

Member Avatar for CppBuilder2006
0
118

The End.