48,985 Topics

Member Avatar for
Member Avatar for euclid135

Hi all, I want to use some container for this case: i have 4 elements, say string1,string2,class1,class2. I need string1,string2,class1 to be united, means if i access string1 in this container you'll get class1. The problem is class2 is something flexible, sometimes it can be written, sometimes it can be …

Member Avatar for euclid135
0
113
Member Avatar for atticusr5

hey everyone, newbie programmer here, and i am working on a project to use linked lists, by creating a linked list class. basically i am using old code and modifying it to work with a linked list class. i am using visual studio to debugg, and it seems that my …

Member Avatar for atticusr5
0
161
Member Avatar for buzzykerbox

This is an assignment for class,design a hangman program,I convert the letters of the random word to charchters,when the user inputs there letter how do I compare that with the secret word, and display it,any suggestions???? [CODE] for(int i = 0; i<word_to_guess.size();i++) { word_to_guess[i] = 'X'; } cout<<word_to_guess<<endl<<endl; while (lives>0 …

Member Avatar for Lerner
0
178
Member Avatar for artikapri

i hav 2 forms Form1 n Form2 in visual studio c++ 2005.i called form2 from the form1 thru a button which is in form1. Using the following code form2 opens but form1 is still visible behind form2. [code]Form2().ShowDialog(); Form2().Activate(); Form1().Close();[/code] i want only form2 to be visible .how can i …

Member Avatar for jephthah
0
48
Member Avatar for random12810

I have no idea how to move a bitmap with the arrow keys. Here is my code [CODE] #include <windows.h> #include <tchar.h> #include <stdlib.h> #include <string.h> #include "Menu.h" #include "Icon.h" LPCTSTR ClsName = L"App"; // Class name LPCTSTR WndName = L"WindowsAPI"; // Window title HWND hwnd; // Handle to our …

Member Avatar for strmstn
0
2K
Member Avatar for gcochra1

I have a list from the stl called Clist. It has alot of items in it and one is a double called fVal. I want to insert new nodes in the list in ascending value according to the fVal. I have tried the following code and it works fine for …

Member Avatar for Lerner
1
101
Member Avatar for tallygal

We are doing an assignment that reads from a file on the hard drive, asks for user input and then writes it to a different file on the hard drive. We have to use three different functions, besides the main, and cannot use global variables. I cannot seem to get …

Member Avatar for tallygal
0
129
Member Avatar for allaboutdrew

Hi all Could someone please explain this program to me, especially lines 25 and 30. I understand that line 30 is a for loop and I understand how it works. However, I am unclear why it is minusing 3 from n and is n the variable passed from line 14? …

Member Avatar for allaboutdrew
0
197
Member Avatar for trantran

This is likely a stupid question, but I can't figured out by myself how to pass a pointer to a member function of a templatised class in its own template parameters. More clearly: I would like to have this to work out: [code]template <typename T, T test::* PtrToMember> class test{ …

Member Avatar for trantran
1
555
Member Avatar for random12810

Which is better Double Buffering or assigning to a Static Control. I would like an example of double buffering or both. This is my bitmap code. [CODE] #include <windows.h> #include <tchar.h> #include <stdlib.h> #include <string.h> #include "Menu.h" #include "Icon.h" LPCTSTR ClsName = L"App"; // Class name LPCTSTR WndName = L"WindowsAPI"; …

Member Avatar for random12810
0
292
Member Avatar for AltF4me

I'm developing a doubly linked list. Now the way I'm currently navigating it is by using a current position pointer, that starts at the tail and then loops round however many times you need (you'll tell the function) and it will then get to that node. Now, I'm having to …

Member Avatar for AltF4me
0
120
Member Avatar for Macbeth

Hi, coders. I have to overload operators +, *, =. Object L3(default "abc") must be smth like this "aabbcc"(operator*; double each symbol of the string). Then I must concatenate Object2 and Object3(operator+), and initialize Object1(operator = ). I have strange errors error C2296: '*' : illegal, left operand has type …

Member Avatar for Banfa
0
186
Member Avatar for mmgoicochea

The program asks to input an integer larger than one. the number is then passed into a function that calculates the sum of squares from 1 to that integer the output should be the value of the integer and the sum(labeled). A negative input value signals the end of the …

Member Avatar for mmgoicochea
0
193
Member Avatar for bandit711

Cant figure out whats wrong with code. This is code should "write a program to compute the interest due, total amount due, and the minimum payment for a revolving credit account. The program accepts account balance as input from a file, then adds on the interest to get the total …

Member Avatar for bandit711
0
285
Member Avatar for karthik.c

hi guys, im trying to do map in cpp using STL and when i ran a simple program it was showing error that: error: nomatchfor'operator<<'in'std::cout<<(&mp0_iter)->std::_Rb_tree_iterator<_Tp>::operator* [with _Tp = std::pair<const int, int>]()'.... my program was like this: [code=c++] #include<map.h> #include<iostream.h> int main() { map<int,int>::iterator mp0_iter; map<int,int>mp0; map<int,int>mp1; mp1.insert(1,13); mp1.insert(2,16); mp1.insert(3,17); for(mp0_iter=mp1.begin();mp0_iter!=mp1.end();mp0_iter++) …

Member Avatar for alvinyang
0
491
Member Avatar for gnarlyskim

Say I have an array: array={1, 2, 3} but I want to be able to increase the size, and shift the data to the front, leaving 0's behind. So i want the array to turn into this: array={1, 2, 3, 0, 0} Where I added two to the size of …

Member Avatar for gnarlyskim
0
144
Member Avatar for PTRMAN1

This exercise had me build on an earlier program - first ask user if wants to compute, then (if yes) choose circle or rectangle, then prompt for appropriate inputs, calculate, and run again. I had a major brain freeze, such that this has taken me many hours just to get …

Member Avatar for PTRMAN1
0
94
Member Avatar for misterjay3

Can someone help me with this???? [CODE]/****************************************************/ /* File: name of your file with the source code */ /* */ /* Created by: give your name */ /* Date: give the date */ /* */ /* Program to find the maximum of three */ /* floating point numbers */ /* …

Member Avatar for Sumyungi
0
114
Member Avatar for Sumyungi

Is there a way in C++ to handle unexpected errors? Other languanges I have learned tend to allow this but for some reason I cannot get the try/catch solution to work in all cases. Take the following example: [CODE] int main(){ vector<int> v; try{ //next line should cause an assertion …

0
55
Member Avatar for athlon32

Hello all, I recently was reading some code and i found something along the lines of this: [code="C++"]void GetText() { int* size = new int; // ....... // lots of code here // ....... size = new int; // crap here }[/code] ^^ as you can see size is 'new'ed …

Member Avatar for strmstn
0
77
Member Avatar for bill_

I am trying to read and write a text file into an array and then store it back into the text file. The main problem i am having is the storing the file character by character into the 3D array. Here is my code: [code] #include <iostream> #include <fstream> using …

Member Avatar for bill_
0
450
Member Avatar for pinsickle

[CODE]class Array { public: Array (int newSize, int order); Array (const Array& original); ~Array (void); void write (ostream& outfile, char* sortName, char* orderName); int getSize (void); void insertionSort (void); void selectionSort (void); void bubbleSort (void); static void initShellH (void); void shellSort (void); void heapSort (void); void quickSort (void); void mergeSort …

0
84
Member Avatar for jeffjnsb

I am writing a Savings account program using a class with methods but it won't compile. I can't seem to figure out why. Hhere is my program. It contains an header file, source code file, and a program cpp file: Here is part of the error I get, C:\Users\JEFF~1.JEF\AppData\Local\Temp\ccWScaaa.o(.text+0x17a) In …

Member Avatar for jeffjnsb
0
642
Member Avatar for strmstn

I developing a small program that I want working as a widget, and would like to display it only when no window has focus - or when the desktop window has focus. My best chance now is finding whether GetFocus() returns NULL but this is not working as suspected. I've …

Member Avatar for strmstn
0
257
Member Avatar for Beasts

for starters im just learning C++ so forgive my ignorance... that being said... i need to pull 3 bits of info out of a text file. - Last name (name) - stored as a string - First initial (initial) - stored as a single character - Account balance (account) - …

Member Avatar for Beasts
0
150
Member Avatar for msgeek

I want to download Image file from web using c++ and save it in specified folder. How to do it?... please help me.

Member Avatar for kooia
0
105
Member Avatar for petteyg

[url=http://cc.byexamples.com/2007/04/08/non-blocking-user-input-in-loop-without-ncurses/]code from this blog[/url] [code]int kbhit() { struct timeval tv; fd_set fds; tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); //STDIN_FILENO is 0 select(STDIN_FILENO+1, &fds, NULL, NULL, &tv); return FD_ISSET(STDIN_FILENO, &fds); }[/code] [code]void nonblock(int state) { struct termios ttystate; //get the terminal state tcgetattr(STDIN_FILENO, &ttystate); if (state==NB_ENABLE) { //turn …

Member Avatar for petteyg
0
250
Member Avatar for greatunknown

I have a simple display() method that essentially looks like this [CODE] #include <stdlib.h> #include <iostream> #include <iomanip> #include "Pieces.h" using namespace std; void Pieces::BeginInstruct(int& i){ cout<<endl<<endl; cout<<i++<<":"<<setw(5)<<"Open the program."<<endl <<i++<<":"<<setw(5)<< "Click \"File\" and then\"New\"." <<endl; } [/CODE] Theres obviously more but what I am concerned with is that setw() …

Member Avatar for greatunknown
0
274
Member Avatar for Frederick2

Been studying what I thought was a fairly authoritative article about BSTRs by Bruce McKinney... [url]http://www.ecs.syr.edu/faculty/fawcett/handouts/cse775/Presentations/BruceMcKinneyPapers/COMstrings.htm[/url] where he states that the four bytes before the start of the BSTR contains the string's length. Here is the exact quote... [QUOTE] What Is a BSTR? The BSTR type is actually a typedef, …

Member Avatar for Frederick2
0
1K
Member Avatar for dusktreader

The essential problem is to determine the index i of the first Fibonacci number Fn to have at least d digits. The specific challenge is to determine the index of the first Fibonacci number to have 1000 digits. Obviously, this problem could be brute forced by stepping through all the …

Member Avatar for dusktreader
0
144

The End.