436 Posted Topics

Member Avatar for Eric_

[QUOTE]cannot convert parameter 2 from 'LPDIRECTSOUND8' to 'LPDIRECTSOUND8 *'[/QUOTE] This probably means that parameter 2 is an output parameter and needs to be a pointer: [code=cplusplus] HRESULT hr = DirectSoundCreate8(NULL, &ppDS8, NULL); [/code] I do not know much about the DirectSound API, so that is the best I can help …

Member Avatar for Eric_
0
183
Member Avatar for jasonjinct

You know how to use 1D arrays, right? 2D arrays are 1D arrays where every item is an array. C has arrays of arrays instead of true multidimensional arrays: [code] int a[5] = {1,2,3,4,5}; [0] -> [1][2][3][4][5] int b[3][2] = { {1, 2}, {3, 4}, {5, 6} }; [0] -> …

Member Avatar for vali82
1
123
Member Avatar for chaithanyap

Your class only allows one name, you need to define an array of 3 names and then use it as an array in the methods: [code=cplusplus] class A { int a[3]; char name[3][20]; public: void read(); void display(); }; void A::read() { cout<<"enter rno name"; for(int i=0;i<3;i++) { cin>>a[i]; cin>>name[i]; …

Member Avatar for chaithanyap
0
129
Member Avatar for atch

Your inner loop does not account for the name being accepted and there is no way to break out of it without somehow signaling a character that has a value of 0. This will work better: [code=cplusplus] while (!name_accepted && cin.get(ch)) [/code] Otherwise the code works fine.

Member Avatar for atch
0
181
Member Avatar for jake43

[QUOTE]I need to know how to calculate the standard deviation?[/QUOTE] Do you know what the standard deviation is and how to calculate it on paper? The standard deviation of a set shows how the items in the set are dispersed. If the standard deviation is low, the items tend toward …

Member Avatar for Tom Gunn
0
620
Member Avatar for yasaswyg

[QUOTE]I need to display Example 23.4 and display 23 and .4[/QUOTE] One easy way is with the type system. When you cast a floating point value it cuts off the precision. If you subtract that result from the original, you get the precision: [code=c] double d = 23.4; double w …

Member Avatar for 42Wired
0
294
Member Avatar for dennis.wu

[QUOTE]Could I suppose this is the rules of c++?[/QUOTE] Yes. The methods of a class can see everything in the class regardless of the access level. That is because a class can always see its own privatemost stuff. This is all at the class level, not the object level. When …

Member Avatar for dennis.wu
0
146
Member Avatar for selsium

That error means those are either functions or objects that have been declared but not defined. A common cause is forgetting to give a body to one of your functions: [code=cplusplus] void function(); int main() { function(); // error! } [/code] Another is including the headers for a library but …

Member Avatar for WallyBags
0
77
Member Avatar for Nogat21

Can you explain your design? A Frame is an Mp3, but an Mp3 has a list of Frames, so an Mp3 has a list of Mp3s? Why does Frame need to inherit from Mp3? That does not make sense to me, but I admit that I only know enough about …

Member Avatar for Nogat21
0
203
Member Avatar for adel_elrefaey

[QUOTE]File:f:\dd\vctools\crt_bld\self_x86\crt\src\[B]fgetc[/B].c Expression: ([B]stream !=NULL[/B])[/QUOTE] This is an easy one. The stream you passed to fgetc is NULL. It means fopen returned NULL because the file could not be opened for some reason. Check the result before using it: [code=cplusplus] FILE* fp = fopen(file, mode); if (!fp) { perror("fopen"); exit(EXIT_FAILURE); } …

Member Avatar for adel_elrefaey
0
739
Member Avatar for Roguey

You do not need to pair isupper and tolower. If the character passed to tolower does not have a lower case equivalent then the same character will be returned: [code=cplusplus] #include <iostream> #include <string> #include <cctype> int main() { using namespace std; string input; cout << "Enter a word: "; …

Member Avatar for mrnutty
0
447
Member Avatar for CD-4+

Opening curly braces need to be matched with closing curly braces. The braces keep the stuff inside from falling out and choking the compiler. :D [code=cplusplus] // class definition class MyClass { public: // public stuff private: // private stuff }; // close the definition [/code] [code=cplusplus] // method/function definition …

Member Avatar for dgr231
0
160
Member Avatar for franksmule

Static methods are called like this: [code=cplusplus] UIClass::GetStatic( IDC_OUTPUT )->SetText( wszOutput ); [/code] Replace UIClass with the name of the class for g_SampleUI.

Member Avatar for Tom Gunn
0
136
Member Avatar for nalasimbha

This is a pretty rough hierarchy. There is still one ambiguity because you do not virtually inherit B in D and F, so there will be two instances of B in H. If you fix that, then H will have one copy of each class all the way up to …

Member Avatar for nalasimbha
0
91
Member Avatar for Jason123

[QUOTE]1) to get the range of elements such as .. A list of 10 elements beginning from value 1 to 10. I would like to get the range from element 3 to element 5 and add them to another list. Is it possible?[/QUOTE] Yes, it is possible. A list is …

Member Avatar for Tom Gunn
0
100
Member Avatar for zahidaiub

[QUOTE]Is not Turbo C a nd Turbo C++ very outdated?[/QUOTE] Yes, but so is DOS. He wants to write code for DOS 6.x, so Turbo C++ is not as bad a choice as it would be if he were targeting a modern OS.

Member Avatar for Salem
0
196
Member Avatar for 666kennedy

To cut from the right, you can take a substring of a smaller length: [code=csharp] string q = s.Substring(0, s.Length - 2) + somethingElse; // replace "mv" with something else [/code]

Member Avatar for ddanbe
0
144
Member Avatar for katwalatapan

Array variables are converted to pointers for value operations. You do not need to do anything special if you already have a pointer. The syntax is basically the same as with an array variable except you have more options with pointer arithmetic: [code=c] #include <stdio.h> int main() { int a[] …

Member Avatar for Tom Gunn
0
118
Member Avatar for hardy1986

The errors are telling you that Turbo C++ is almost 20 years old and it is time to move to a newer compiler that does not need a DOS emulator to run your programs in 16 bit mode. ;) Really, there is no point in learning to do graphics with …

Member Avatar for Tom Gunn
0
140
Member Avatar for miankhel

[QUOTE]So I have two functions, both which have the same name, but based on the TYPE of the parameter passed do two separate things[/QUOTE] You described function [URL="http://en.wikipedia.org/wiki/Method_overloading"]overloading[/URL], not [URL="http://en.wikipedia.org/wiki/Method_overriding_%28programming%29"]overriding[/URL]. Overriding is replacing the implementation of a method with a specialized implementation in a derived class.

Member Avatar for ShawnCplus
0
115
Member Avatar for atch

Not without doing some kind of explicit mapping: [code=cplusplus] #include <iostream> #include <string> enum Color {Red, Blue, Green}; static std::string ToString(Color color) { switch (color) { case Red: return "Red"; case Blue: return "Blue"; case Green: return "Green"; default: return ""; } } int main() { Color color = Red; …

Member Avatar for wildgoose
0
96
Member Avatar for muusa

Two instances of undefined behavior, three if your compiler does not support void main. [LIST=1] [*]The i variable is uninitialized. Anything could be in that memory space, and you are not allowed even to read it. [*]A sequence point is only guaranteed after all of the function arguments are evaluated. …

Member Avatar for muusa
0
119
Member Avatar for RobBrown

You can use any sorting algorithm with the right comparison: [code=c] #include <stdio.h> #include <stdlib.h> int compare(void* const a, void* const b) { int const ia = *(int const*)a; int const ib = *(int const*)b; return (abs(ia) % 2) - (abs(ib) % 2); } int main() { int a[] = …

Member Avatar for Tom Gunn
0
140
Member Avatar for duggydiggy

There probably will not be a definition of [ICODE]a[/ICODE] like that. If the variable is local, it will probably be defined as an offset on the stack. Look for changes to esp and ebp: [code=c] void Function() { int a; [/code] Might look like this for whatever flavor of assembly …

Member Avatar for Salem
0
200
Member Avatar for Lioshenka

[QUOTE][CODE]char info; [/CODE][/QUOTE] info is not a string, it is a single char. That explains why you only get the first character of the surname. Change info to an array of 255 like the surname array in the user structure, or change the type to an object of the user …

Member Avatar for Tom Gunn
0
70
Member Avatar for tux4life
Member Avatar for Ancient Dragon
1
285
Member Avatar for Hawkpath

If you want to manually refactor, I like to start with a simple function call and cut the code into a new function with that name: [code=cplusplus] void BottomTurn() { a = front[6]; b = front[7]; c = front[8]; front[6] = left[0]; front[7] = left[3]; front[8] = left[6]; left[0] = …

Member Avatar for Hawkpath
0
107
Member Avatar for revenge2

[QUOTE]Or loop through the string and check if any char is between the acsii value's of '0' and '9'.[/QUOTE] Or just compare against '0' and '9' because the values have to be contiguous and using the underlying values means your code is tied to ASCII and any other character sets …

Member Avatar for Hiroshe
0
5K
Member Avatar for bernadlosini

Your function generates a random number in the range of [0..RAND_MAX), not in the range of [1..5). The easiest trick for fixing the range is the remainder operator: [code=cplusplus] i = rand() % 4 + 1; [/code] The remainder of division from RAND_MAX by 4 will always result in a …

Member Avatar for mrnutty
0
236
Member Avatar for ddanbe

I think a property is better because the method has extra syntax that is not needed. But they both do the same thing and are close enough that you should pick the one you like better. [QUOTE]Suppose I want to derive from a Square class, call it a SuperSquare class, …

Member Avatar for sknake
0
77
Member Avatar for Dream2code

Read them the same way you read ASCII files, but you need to convert each character to the right character set once you read it or any output will be jumbled. There are conversion charts all over the web, and the process is simple. [URL="http://www.simotime.com/asc2ebc1.htm"]Here[/URL] is one of those charts.

Member Avatar for yellowSnow
0
1K
Member Avatar for Curgol

[QUOTE]It's not because you quickly want to test out some code that you may use bad coding styles. Bad coding styles are considered: bad, so you don't have to use them, under any circumstances.[/QUOTE] That rationalization might work when you preach to the choir, but everyone else needs a better …

Member Avatar for Curgol
0
2K
Member Avatar for swinefish

Please do not roll your own encryption code. It's fine for a homework exercise but anyone who uses that kind of thing in a real application needs to be shot. ;) At the very least, if you do not care about how strong the encryption is, use the libraries offered …

Member Avatar for swinefish
0
288
Member Avatar for Curgol

fscanf can read 2 digit hex numbers: [code=c] #include <stdio.h> int main() { unsigned char binary[16] = {0}; unsigned int hex; int x, y; for (x = 0; x < 16 && fscanf(stdin, "%2x", &hex) == 1; ++x) binary[x] = (unsigned char)hex; for (y = 0; y < x; ++y) …

Member Avatar for Curgol
0
489
Member Avatar for alvalany

[QUOTE]Can someone suggest me some way to increase my interest in C by giving examples of some marvellous things that can be done in C and CPP.[/QUOTE] If you need random anonymous people online to help you get interested, you are not interested enough. Maybe another language where you can …

Member Avatar for sftwr21
0
201
Member Avatar for tintincute

You can do it with the KeyPress or KeyDown event for the text box. Both of those have event args that tell you what key was pressed.

Member Avatar for tintincute
0
391
Member Avatar for Shaitan00

When the compiler complains about dependent names, it means you need to use the [URL="http://www.comeaucomputing.com/techtalk/templates/#typename"]typename[/URL] keyword to fix an ambiguity: [code=cplusplus] template<typename T> class List { public: class A { }; A begin() const; }; template<typename T> typename List<T>::A List<T>::begin() const { return A(); } [/code]

Member Avatar for Tom Gunn
0
356
Member Avatar for goody11
Member Avatar for declain

infile is local to the if statement and the file gets closed when the if statement ends. Inside the loop, the file is closed, the object pointed to by the pointer is gone and you are not allowed to dereference the pointer anymore. Even if you have a pointer to …

Member Avatar for declain
0
161
Member Avatar for johnysums

Static members of a class still need to be defined outside of the class, and in a file that will not be included multiple times like a header: [code=cplusplus] // globals.h #include <string> struct car { std::string type; std::string brand; std::string manufacturer; std::string engine; int cylinders; std::string tyres; }; public …

Member Avatar for Tom Gunn
0
149
Member Avatar for serkan sendur

For a good block cipher the responsible thing to do is change the constraint to expect cipher text length instead of plain text length or change the limit of the plain text to be short enough to meet the current database constraint. If you use a block cipher it is …

Member Avatar for Tom Gunn
0
513
Member Avatar for Annex31b

You can do it, but I think a better way is to have a Clone() method in the Animal class that the child classes override. Then all you need to do is this: [code=csharp] foreach (Animal d in AnimalBufferList) { Add(d.Clone()); } [/code]

Member Avatar for sknake
0
163
Member Avatar for walter clark

[QUOTE]Can anyone recommend another book or website that lists all the C++/CLI functions and classes? Perhaps one that just is just a list with maybe one short example each?[/QUOTE] You just described [URL="http://msdn.microsoft.com/en-us/library/aa139615.aspx"]MSDN[/URL].

Member Avatar for Stefano Mtangoo
0
226
Member Avatar for teddyg18

[QUOTE][CODE] iTemp = inFile >> day[numRecords]; iNew = inFile >> score[numRecords]; [/CODE][/QUOTE] iTemp and iNew are being assigned references to inFile, those values are not meaningful to you. I guess you wanted iTemp to match day[numRecords] and iNew to match score[numRecords]: [code=cplusplus] inFile >> day[numRecords]; inFile >> score[numRecords]; iTemp = …

Member Avatar for teddyg18
0
160
Member Avatar for Tom Gunn

My name is Tommy, and I am a computer consultant/programmer in the USA. C# and C++ are my primary weapons, and most of my work these days is .NET based for data capture, processing, storage, and retrieval. My hobbies are gaming, music, ultimate frisbee, and cooking. My personality type is …

0
38
Member Avatar for elidotnet

Show the login form first, then if the login is successful, open the MDI form from the login form: [code=csharp] void buttonLogin_Click(object sender, EventArgs e) { string user = textBoxUser.Text; string pass = textBoxPass.Text; if (IsValid(user, pass)) { new MainForm().Show(); Hide(); } else { MessageBox.Show("Invalid user name or password"); } …

Member Avatar for kvprajapati
0
115
Member Avatar for scarypajamas

[QUOTE]Is it because my float values are too big?[/QUOTE] Or too small. Or too precise for fixed notation. You can print the usual way with the [ICODE]fixed[/ICODE] manipulator. [code=cplusplus] #include <iostream> using namespace std; int main() { double d = -4.49255e+013; cout << fixed << d << '\n'; } [/code] …

Member Avatar for necrolin
0
110
Member Avatar for Creator07

[QUOTE]I am not using any features of .NET as I know of. So, why does Visual Studio always ask me to target a Framework in my project.[/QUOTE] Make sure you do not have the /clr switch anywhere in your compiler command line options. C++/CLI compiles native C++ to a CLR …

Member Avatar for Creator07
0
199
Member Avatar for harryhaaren

Good OO design is like good code. You know it when you see it, but it is not something that can be taught. There are [URL="http://ootips.org/"]guidelines[/URL] to get started, but the real teacher is experience with what works and what does not.

Member Avatar for harryhaaren
0
100
Member Avatar for rcbhat

[QUOTE=jephthah;915989]yes, you're right. even though it works for this trivial example, not casting it properly is a bad habit to get into. the correct way to initialize it is: [code]char q[16]; char *p = [color=red][b](char *)[/b][/color]&q; strcpy(q,"abc");[/code][/QUOTE] So you get the wrong type, then cast it to the right type …

Member Avatar for Alibeg
0
518

The End.