6,741 Posted Topics

Member Avatar for Lumin0us

The color you want is [ICODE]initColor(FOREGROUND_GREEN | FOREGROUND_INTENSITY)[/ICODE]. And it's generally more informative to use the macros rather than hardcoded values.

Member Avatar for Lumin0us
0
116
Member Avatar for Takarakujin

[B]>you get a nice code looking like this[/B] Well, it could be worse. [B]>printf("\nEnter the size for the characters:");[/B] There are three times when the output buffer is flushed: [LIST=1] [*]It becomes full. [*]A newline character is printed. [*]The code calls fflush on the output stream. [/LIST] For obvious reasons …

Member Avatar for Software guy
0
81
Member Avatar for johndoe444

[B]>My intuition is that that has to be decided on application requirement.[/B] Your intuition is correct. It depends on how much precision needs to be involved in the test. I've used as little precision as 0.1, myself. [B]>are we supposed to represent the numbers in string instead?[/B] That's always an …

Member Avatar for jephthah
0
185
Member Avatar for tennis

[B]>Is this the right answer?[/B] Somewhat. You can access the derived parts of the object if the pointer points to a derived class object. But you can't do it directly unless those parts are inherited and/or shared through polymorphism. Otherwise you would need to downcast. But technically after downcasting you're …

Member Avatar for Narue
0
79
Member Avatar for d883956

The precision of a stream persists after the call even if you use the manipulator. You can save the old value though, and reset it to what it was before: [code] streamsize old = cout.precision(2); cout<< fixed << jax <<'\n'; cout<< setprecision(old) << jax <<'\n'; [/code]

Member Avatar for Narue
0
121
Member Avatar for johndoe444

[B]>how does long and long long differ?[/B] long was originally intended to be 32 bits and long long to be 64. These are the minimum limits though, so as the need for longer types grows, they could grow to accommodate it. [B]>Was short type ever was 1 byte and changed …

Member Avatar for Ancient Dragon
0
203
Member Avatar for johndoe444

[B]>why is constructor of Base is also being called[/B] Because the Base part of the Derived object still needs to be constructed. This is done with the Base constructor. Think of it as an implicit call to the Base constructor: [code] Derived(): Base() { cout<<"Constructor: Derived"<<endl;} [/code] [B]>Why is the …

Member Avatar for Narue
0
167
Member Avatar for johndoe444

<iostream.h> is the pre-standard version if <iostream>. Modern compilers are quickly dropping pre-standard support. Note that a .h extension is [i]not[/i] implied if you omit it. The two header names are completely different.

Member Avatar for craig_ka
0
144
Member Avatar for johndoe444

[B]>Does endl do the same thing as %n in java and print >the platform dependent end of line ('\n', \n\r' or '\r')?[/B] If the stream is text oriented rather than binary, yes.

Member Avatar for Narue
0
72
Member Avatar for ischuldt

I think they're both hideous, but mostly because you didn't use code tags properly. [B]>mostly i'd like thoughts on the single return vs the triple return.[/B] There are good arguments both ways. It's a preference thing unless you're bound by an employer's coding guidelines.

Member Avatar for Fbody
0
136
Member Avatar for gregarion

[B]>int num ;[/B] Don't forget to initialize your variables. This should be [ICODE]int num = 0;[/ICODE] since all you're doing afterward is adding to it. That's the cause of your weird numbers. [B]>if (numeral[n] =='M')[/B] There's no loop here, so you'll only test [ICODE]numeral[0][/ICODE]. [B]>cout << num << endl;[/B] Assuming …

Member Avatar for gregarion
0
255
Member Avatar for metdos

[B]>How Can I Increase Scope of "temp" object?[/B] Define it at a higher scope? :icon_rolleyes: Your example is especially nonsensical because when the if body isn't executed, you'll have an uninitialized pointer to contend with. Usually in cases like this one we use dynamic memory: [code] MyClass *stable = 0; …

Member Avatar for mattjbond
0
177
Member Avatar for vbx_wx

[code] if ( GetAsyncKeyState ( VK_SHIFT ) && GetAsyncKeyState ( 0x41 ) ) { // SHIFT+A combination pressed } [/code]

Member Avatar for Narue
1
154
Member Avatar for cblue

Apparently you don't trust the people you ask questions to. Otherwise you wouldn't post the same question on multiple sites. That's a pet peeve of mine, so if you're going to post identical threads and identical replies, at least include what you've been shown in your identical thread on the …

Member Avatar for jai verma
0
246
Member Avatar for bertyhell

[B]>This should be most performant unless Narue says otherwise[/B] AFAIK, country codes are organized in a prefix hierarchy, so a trie would be the most direct data structure for the hierarchy. Obviously reusing an existing library is ideal, but because there aren't many country codes, you could use just about …

Member Avatar for bertyhell
0
4K
Member Avatar for Xufyan

[B]>how can i write a code for three conditions ?[/B] I assume you're looking for the ugly nesting solution: [code] int d = a < b ? a < c ? a : c : b < c ? b : c; [/code] Which looks a lot like line noise …

Member Avatar for jephthah
0
142
Member Avatar for josolanes

[B]>Okay, while continuing to search, I came up with this: >[url]http://msdn.microsoft.com/en-us/libr...=VS.80%29.aspx[/url][/B] _Smanip is a Microsoft-ism. Don't expect code using it to compile anywhere except Visual C++. The concept behind _Smanip is trivial anyway: [code] #include <iostream> #include <iomanip> struct fillblank { int _l; fillblank ( int l ): _l ( …

Member Avatar for josolanes
0
369
Member Avatar for karthik.c

>cout << *mp0_iter.first() << *mp0_iter.second() << '\n'; This won't work, for several reasons. To begin with, first and second are not member functions. Also, the member operator binds more tightly than the indirection operator, so you're trying to call the first and second member functions (which still don't exist) on …

Member Avatar for alvinyang
0
500
Member Avatar for lionaneesh

const is a qualifier for objects that tells the compiler you won't try to modify the object's value: [code] int x = 10; const int y = 10; x = 20; /* Okay */ y = 20; /* Bzzt! y is const */ [/code] const is short for constant, which …

Member Avatar for jephthah
0
120
Member Avatar for jasneg16

[B]>i was trying to find code or solution without using stdlib.h[/B] Unless you need something stronger than rand, it's best to keep to the standard libraries. However, implementing [URL="http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_rand.aspx"]your own random number generator[/URL] is an entertaining exercise. [B]>May I ask if Is it safe to download Turbo C in brothersoft.com[/B] …

Member Avatar for WaltP
0
147
Member Avatar for lionaneesh

[U][B]Simple and Brief Command Line Tutorial[/B][/U] [I]by Narue[/I] Command line arguments are sent to a C program through two parameters in main. The first parameter specifies the number of command line arguments. The second parameter is an array of strings listing each command line argument: [code] #include <stdio.h> int main …

Member Avatar for Narue
-1
250
Member Avatar for spursfan2110

Have you checked a C reference? We're generally miffed when people ask questions that are easy to look up.

Member Avatar for Narue
0
123
Member Avatar for Iam3R

[B][U]Nested Comments[/U][/B] [B]>1. Why Nesting of comments is not supported by c. >code does not involve much complexity to have that.[/B] Because it adds unnecessary complexity to the grammar and as a result, the compiler. Since a language feature already exists which handles the intended function of nested comments (ie. …

Member Avatar for Narue
0
287
Member Avatar for formulajake88
Member Avatar for jephthah
0
510
Member Avatar for priyankapandey

[B]>which we can later type cast to any data type, and with >this we can traverse our 2 dimensional array... [/B] Um, no. void** doesn't have the same generic properties as void*. Rather than a pointer to a pointer to an unspecified type, void** really is a pointer to void*. …

Member Avatar for Narue
0
1K
Member Avatar for Dabdob

And this works? It's better if you mention whether the code works or not so we can adjust our comments accordingly. Here are the things that I took note of: >MOV BX,AS; This looks like a typo, and you probably meant AX. You also don't need to terminate a statement …

Member Avatar for ashenafiye
0
7K
Member Avatar for Ajantis

[B]>I was just wondering if anyone knows where I can find >a GOOD tutorial on Red Black trees in JAVA?[/B] [URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx"]This tutorial[/URL] uses C, but it's easily translated into Java. I think it's one of the better ones out there, but I'm biased. :D [B]>I was reading the Mark Allen …

Member Avatar for Rashakil Fol
0
91
Member Avatar for COKEDUDE

[B]>I thought the swap function was defined in #include <stdio.h>.[/B] You guessed wrong[1]. Maybe instead of thinking from a position of ignorance, you should do some [URL="http://www.dinkumware.com/manuals/#Standard%20C%20Library"]research[/URL] and enlighten yourself. [1] In some parallel universe where the standard C library contains a swap function, it would most likely be in …

Member Avatar for Narue
0
168
Member Avatar for COKEDUDE
Member Avatar for Narue
0
100
Member Avatar for Colin Mac

>The program works but I'm wondering if I should make a new file called enemy.h You can if you'd like. I don't see any benefit for it at this point though.

Member Avatar for virgoptrex
0
184
Member Avatar for jephthah

[B]>On June 21 2009, Narue disappears off the face of the Daniweb planet.[/B] As she does occasionally due to real life concerns and lack of interest. This is common knowledge, and a running joke, I think. [B]>Then on 13 November, Tom Gunn abruptly disappears as quick as he >appeared, vanishing …

Member Avatar for jephthah
3
681
Member Avatar for cblue

>x(!)^n >Factorial(pow(current,power)) Either your mathematical notation is wrong, or your code is. And the parens are mildly confusing, can you be more specific as to their purpose?

Member Avatar for forough95
0
224
Member Avatar for sean108

>Can some one give me some code on how to use windows.h.... windows.h is one of the headers you use for the Win32 API. It's not something you can learn with just a bit of sample code. [url=http://www.foosyerdoos.fsnet.co.uk/]This[/url] is a good start, though.

Member Avatar for kendapcwiz
0
519
Member Avatar for chetanbasuray

[B]>Please guide me so as i can check if the password value in >the database is same as the one entered in the text box.[/B] Send the one entered in the text box to a stored procedure which checks for matches against the selected user. [B]>I have no idea how …

Member Avatar for kplcjl
0
109
Member Avatar for omar isaid

If you don't expect the first character to actually be whitespace, you can use "%*s". Otherwise, because %s ignores leading whitespace, you would need to use an exclusion scanset of whitespace: [code] fscanf ( in, "%*[^ \n\t\r\f\v]" ); [/code]

Member Avatar for omar isaid
1
3K
Member Avatar for Iam3R

[B]>which one is the correct one to use, what is the problem with others.[/B] They're all correct in certain situations, but one is unconditionally correct: [code] int main(void) { return 0; } [/code] Let's go from top down. [QUOTE][code] main() { } [/code][/QUOTE] This definition won't compile under C99 because …

Member Avatar for nezachem
0
226
Member Avatar for Kushal Thakkar

>the rest of the time they should be avoided because they violate OOP data encapsulation. If this is what you think, then you're not in a position to help. Those who still need to learn shouldn't be teaching.

Member Avatar for Dave Sinkula
0
2K
Member Avatar for domingo

The problem is getting an object from your data reader rather than a time span. You need to cast before doing the relational test.

Member Avatar for kplcjl
0
197
Member Avatar for TobbeK

I'd read it as a string and then parse it using a suitable culture: [code] using System; using System.Globalization; namespace JSW { static class Program { static void Main() { string test = "12345,67"; CultureInfo german = CultureInfo.CreateSpecificCulture("de-DE"); Console.WriteLine("Default: " + decimal.Parse(test)); Console.WriteLine("German: " + decimal.Parse(test, german)); } } } …

Member Avatar for TobbeK
0
2K
Member Avatar for Freespider

Well, since -1 in both fields is your stopping case, you can use that as an "empty" instance.

Member Avatar for Narue
0
102
Member Avatar for Dani

>Homework and selfstudy can be completely different things. In this case, "homework" means a personal project that you have a vested interest in completing, and we don't care about. It could be actual homework from a class, self-study from a textbook, or even something you imagined up. Regardless of how …

Member Avatar for BestJewSinceJC
5
4K
Member Avatar for mrblippy

[B]>Is the running time of this code expressed as O(n)???[/B] Well, n is your base count, and the loop always multiplies that by itself. The behavior is really no different from this: [code] for (int i = 0; i < n; i++) { for (int j = 0; j < …

Member Avatar for Narue
0
136
Member Avatar for tajendra

[B]>NULL is not preferred.[/B] Nice backtrack, but preference is not truth. Bjarne Stroustrup is well known for disliking certain features inherited from C, and macros are one of those features. It doesn't mean that NULL is wrong in any way. Let's address his concerns: [QUOTE=Stroustrup]Another problem with NULL is that …

Member Avatar for tajendra
0
469
Member Avatar for Zany..!

While you [i]can[/i] store blobs and images in a database, it's generally better to store the files on your file system and the location of the files in your database.

Member Avatar for JuhaW
0
109
Member Avatar for Sailor_Jerry

First set the data source for the combobox column as you would for just a regular combo box. Then set the DataPropertyName property for the combobox column to the name of the column you want to bind to in your data set.

Member Avatar for Sailor_Jerry
0
2K
Member Avatar for JohnnyT

Your first example is a syntax error because it's neither a method nor a property. If you add a parameter list, it works and becomes a method: [code] public int ShiftsLeft() { return shiftsToWork - shiftsWorked; } [/code] [B]>Can someone tell me the difference between the two[/B] Methods are named …

Member Avatar for JohnnyT
0
131
Member Avatar for Acidburn
Member Avatar for Narue
0
35
Member Avatar for clutchkiller

[B]>Ive never used XNA before,[/B] So you have no business making any claims about it, much less the people who use it. [B]>It kinda pisses me off.[/B] What a stupid post. I can only conclude that you feel threatened by the competition these easy to use APIs bring to the …

Member Avatar for jwenting
-3
141
Member Avatar for bops

>I was just wondering, is it safe to do something like this? No, an uninitialized pointer doesn't point to infinite usable memory. >Basically, what if it is impossible to calculate the amount >of space required to hold everything in the array? Then you've done something wrong. You should always be …

Member Avatar for Raptor007
0
1K
Member Avatar for trenzkun

[B]>please post an example statement[/B] It's not a single statement. You need to write code to parse and evaluate the expression. This kind of thing is common homework, so you're not going to get much help by begging for code. Try it yourself first, and if you hit a wall, …

Member Avatar for Adak
0
84

The End.