49,761 Topics

Member Avatar for
Member Avatar for MachDelta

Another newbie question here. What's the difference between these two? [CODE]cin.ignore(cin.rdbuf()->in_avail(), '\n'); cin.ignore(numeric_limits<streamsize>::max(), '\n');[/CODE] I understand that the former will ignore only the characters [I]left[/I] in the stream buffer, while the latter tries to ignore characters equal to the [I]size[/I] of the buffer. So the end result should, normally, be …

Member Avatar for MachDelta
0
130
Member Avatar for myrongainz

[CODE]string rev; for(int i =1; i<=(int)user.length();i+=2) { rev = user.length[i+1]; rev = user.length[i]; } [/CODE] this is a part of my code where "user" is the user inputted text. I'm trying to get the output to do this. input - square output - er au qs I've been stuck on …

Member Avatar for myrongainz
0
131
Member Avatar for George_91

I've to make several experiments of some algorithms. I want to send those results to a .txt file [CODE] //.... for (count= 1; count<= 20; count++){ //.... std::cout<<exp<<"Time: "<<duration << " seconds" <<'\n'; ofstream f2; f2.open("results.txt", ofstream::out); for(int i=0; i<=20; i++){ f2<<duration<<endl; } f2.close(); } [/CODE] With this code, I …

Member Avatar for MachDelta
0
182
Member Avatar for Brokenpwn

I recently started reading Beginning DirectX 10 Game Programming written by Wendy Jones, and I'm about 60 pages in on the chapter about sprites, and I feel like I haven't learned anything, half the code they throw at me I can hardly decipher, and even if I do that, how …

Member Avatar for Serapth
0
207
Member Avatar for vishwanath.m

hey guys, i have a problem with this question.. Given n and m, calculate 1^1 + 2^2 + 3^3 + ... + n^n modulo m. here i cant use power function directly as it only works for very very small inputs. Test your code on anything larger and you will …

Member Avatar for StuXYZ
0
200
Member Avatar for George_91

I've this code. I need to do several experiments to obtain de average time it takes to do some methods. Instead of re-running and re-running the program, I want to put a segment of the code in a FOR bucle. The problem is that my program never ends,it stays looping …

Member Avatar for vishwanath.m
0
166
Member Avatar for George_91

I've a vector of size 'n', I need to do random couples with the n numbers (integers) and make a swap between them. Any ideas how? I had this idea [CODE] int low = 0; int temp; for (int high = n-1; i= low; high-- ) { temp = v[high]; …

Member Avatar for George_91
0
186
Member Avatar for learner guy

hi can anyone help me in making this code work ..i will be very grateful to him/her [CODE]#include <iostream> #include <stdio.h> #include <conio.h> #include <windows.h> using namespace std; #define BLACK 0 #define BLUE 1 #define GREEN 2 #define CYAN 3 #define RED 4 #define MAGENTA 5 #define BROWN 6 #define …

Member Avatar for WaltP
0
388
Member Avatar for Vasthor

the program behaviour is different with code that have similar function this [CODE] #include <iostream> #include <string> int main() { int a = 1; while (a < 11) { int b = a++; int c = a * b; std::cout << c << std::endl; ++a; } return 0; } /* …

Member Avatar for Vasthor
0
149
Member Avatar for george08.08

Hello again I am a bit confused about how to show a constant in a class constructor. I have a savings account class (A child class of Account) which has a constant interest rate. I have it in my class as a static constant double INTEREST_RATE;. Then outside of my …

Member Avatar for mzimmers
0
184
Member Avatar for VilePlecenta

Seen it asked for so here it is.[code]#include <Windows.h> #include <iostream> #include <conio.h> using namespace std; #define ClearScreen() system( "CLS" ) class _Notepad { public: _Notepad() { ZeroMemory( &Buffer, sizeof( Buffer ) ); pt.x = 1; pt.y = 1; } void GetUserString(); void SendToChild(); private: HWND nphWnd; POINT pt; char …

Member Avatar for fengdanbailu
0
1K
Member Avatar for george08.08

Hello I am creating a bank account for an assignment and the account number must be automatically generated with consecutive numbers. I have written some code that works, but now I need to know how to use it in conjunction with my Account class, especially how to add it to …

Member Avatar for mzimmers
0
203
Member Avatar for Vasthor

2-4. The framing program writes the mostly blank lines that separate the borders from the greeting one character at a time. Change the program so that it writes all the spaces needed in a single output expression. already google this, but what I got is a bunch of headache... so, …

Member Avatar for Vasthor
0
356
Member Avatar for fatzky_04

HELLO! There is no error and it runs, but it doesn't show my desired output. What is the problem? [CODE]#include<stdio.h> #include<stdlib.h> struct list { int data; struct list *ptr; }; int main() { struct list *clist; struct list *top; struct list *tmpptr; int i; clist=(struct list *)malloc(sizeof(struct list *)); top=clist; …

Member Avatar for raptr_dflo
0
100
Member Avatar for tvm78

So I'm trying to write a program that is due tomorrow. I am trying to overload operators and dealing with template classes. I have everything written already but keep getting this error whenever i try to compile the driver file: NOTE: proj4.cpp has #include "box.h" and box.h compiles fine, but …

Member Avatar for NathanOliver
0
273
Member Avatar for phr33k

Hi, I am new to the forum. I am stuck on this assignment I have to do. I think i have defined the array suitably enough, I just cant implement the sorting specified in the question. Any help would be greatly appreciated. Here is the question: Create a program in …

Member Avatar for dctb13
0
325
Member Avatar for typedefcoder

I have a series of Key value pairs. Each Key has 2 values. Values of Keys ma coincide. Initially i start with Key1, ValueKey1, ValueKey2 are stored in a set.(Maybe Array). Now for each consecutive Keyi, i check if Valuei, Valuei+1 are in the set. If any one of them …

Member Avatar for typedefcoder
0
229
Member Avatar for MachDelta

Hi everyone. First time poster here :) I'm working on my final project for a computing course at university, and I was wondering if anyone knew of a portable library or solution to changing console colours. I understand that such functions are OS specific (I'm working on Win32, but my …

Member Avatar for xfbs
0
187
Member Avatar for Zssffssz

After trying to start writing my long paper "Programing, The Art" I noticed that, getting user imput, conditional statements, using escape charecters, exicuting system commands, and even declaring variables and using them so that they have use; these are all difficult outside of the domain of C and C++, even …

Member Avatar for xfbs
0
242
Member Avatar for Panathinaikos22

Here is my code, i will also give an example... [CODE]#include <iostream> using namespace std; class Encryption { private: int wp, wk, encryption; public: Encryption() { } Encryption(int password, int key) :wp(password), wk(key) { } int Encrypt_Store() { encryption = wp + wk; cout << "Encypted: ( " << hex …

Member Avatar for xfbs
0
181
Member Avatar for Blue Hawk

hi guys .......i am new around here ......would like you suggest something about..."Gaming using C or C++ languages"

Member Avatar for xfbs
0
288
Member Avatar for thenewbiecoder

I have to write a game application that simulates a roulette table. The roulette table has 36 numbers (1 to 36) that are arranged in three columns of 12 rows. The first row has the numbers 1 through 3, the second row contains 4 through 6, and so on. There …

Member Avatar for Clinton Portis
0
362
Member Avatar for rjstamey

Hello all, I am trying to figure out how to create new class objects when the user is asked if he/she would like to. What I have is a program we have to write that takes a certain number of students and keeps track of their name, assignments, and the …

Member Avatar for xfbs
0
468
Member Avatar for i2u2me

Complete TRY THIS Exercise 1, and then modify the IPO chart information and C++ instructions so that the commission rate will always be 10%. How is commission rate set to 10% always? <writing instruction> IPO Chart Inforomation C++ Instructions Input sale1 double sale1 = 0.0; sale2 double sale2 = 0.0; …

-3
132
Member Avatar for collinskawere

why do my programs just flash off the screen when i try to execute them? i am new to programming, don't forget!

Member Avatar for siskaj
0
140
Member Avatar for Jsplinter

class MapClass holds copies of class DataStruct so that instances of class Action only have to store the key value associated with the DataStruct: [CODE]struct DataStruct { friend bool operator< (DataStruct const &lhs, DataStruct const &rhs) { if (lhs.xData < rhs.xData) return true; else if (lhs.xData > rhs.xData) return false; …

Member Avatar for Jsplinter
0
136
Member Avatar for hudsonzp

[CODE] #include <iostream.h> main(){ int balance; int payment; int payment_num = 1; int months = 0; float interest; cout << "Please input a value for the balance" << endl; cin >> balance; cout << "Please input a value for the payment" << endl; cin >> payment; while (balance > 0) …

Member Avatar for WaltP
0
579
Member Avatar for senergy

Hello, I've added TXT file to my resource, but now I need to know how to access data in it? can I use iostream to read data? I have this: resource.rc [code]LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDR_0_1 0 "..\\..\\..\\..\\..\\Desktop\\test.txt"[/code] resource.h [code]#define IDR_0_1 119[/code] main.cpp [code]HRSRC hRes = FindResource(0, MAKEINTRESOURCE(IDR_0_1), "0"); HGLOBAL hData …

Member Avatar for Moschops
0
186
Member Avatar for HASHMI007

[CODE] #include <iostream.h> #include <stdlib.h> template < class ItemType > class stack { private : int top; int maxStk; ItemType *items; public : stack(); stack(int max); int isEmpty(); int isFull(); void push(ItemType newItm); int Pop(ItemType &Itm); }; template <class ItemType> stack <ItemType>::stack(){ top=-1; maxStk=500; items=new ItemType[500]; } template <class ItemType> …

Member Avatar for HASHMI007
0
169
Member Avatar for slygoth

Hey guys. I just learn about magic numbers today. I am trying to make a program that uses fstream along with magic numbers to tell what a file is. Example the magic numbers for jpg are ff d8 ff e0. How do i check a file to see if its …

Member Avatar for Ancient Dragon
0
1K

The End.