49,761 Topics
| |
I have a sockets projects using tcp/ip and it is structured like this: [code] class Socket { int desc; Socket(); // create socket here }: class TCPSocket: public Socket { public: int send(); int recv(); }; class ClientSocket: public TCPSocket { public: void connect(); }; class ServerSocket: public Socket { … | |
In the book I'm studying we are given a function to make rand() work for numbers that are smaller that RAND_MAX [CODE] int nrand(int n){ if(n <= 0 || n > RAND_MAX) throw domain_error("Argument to nrand is out-of-range"); const int bucket_size = RAND_MAX/n; int r; do r = rand()/bucket_size; while(r … | |
I have a program that I've written...basically the problem starts when I reach the condition to hit the following block: [CODE] status = myPubSubSubscribe.Receive(fsReceivedTopic, myBufferSubscribe, myHeader, 0); if (status == PS_ENGINE_UNAVAIL) { printf("Unable to connect to the pubsub engine: %s\n", PSPubSub::Status2String(status)); myBufferPublish.FreeBuffer(); myBufferPublish.~PSBuffer(); myPubSubPublish.~PSPubSub(); myBufferSubscribe.~PSBuffer(); myPubSubSubscribe.~PSPubSub(); return; } [/CODE] In … | |
[CODE]// ---------------------------------------------- // Name: William Rennie // Program: // Description: // ---------------------------------------------- #include <iostream> #include <cstdlib> #include <stdio.h> #include <string.h> using namespace std; // ----------- Function definitions ------------- void printTitle(int gamenumber){ gamenumber++; cout<<"***Word guessing game round "<<gamenumber;} bool checkWord(char word[],char guess[]){ int i; int x=strcmp(word,guess); if (x==0){return true;} else return … | |
Working with large int numbers. Broken up as char for each digit, total of 3 arrays, n1, n2, and sum. I have everything completed, the math works fine, the arrays work fine, the shuffling to the right side of the array works fine. I just have two issues, that both … | |
I need to generate a core file for a crashing process and then read it using dbx - can anyone help me with this? | |
I'm reading about two-dimensional and multi-dimensional arrays at the moment in order to better organize user input. I'm trying to create a function that can store a card player's hand. At the moment I'm just brainstorming how it would look and writing out some notes to myself to organize it … | |
Hey folks, just a quick question i can't seem to find the answer to. If i overwrite a container with a pointer in it, does the pointer and therefore the object it points to still exist, and would that be considered a bad handling of memory. For instance. I have … | |
Hi, Why I get access violation in this code ? [code] char *arr[ 5 ]; for( int i = 0; i < 5; i++ ) cin >> arr[ i ]; [/code] but not in this : [code] char *arr[ 5 ]; char list[ 5 ][ 30 ]; for( int i … | |
Okay here is go this is my first time posting to this website and I hope I can get this all right for you all. I have stated this program and I gt know errors but the program will not run past my first cin cout statements? Does anyone see … | |
Hello Using : [CODE] cout << "enter 5 letter"; getline(cin, letter); [/CODE] executes fine but when running PC- Lint: getline(cin, expectedLabel): error 534: (Warning -- Ignoring return value of function 'std::getline(std::basic_istream<char,std::char_traits<char>> &, std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)' error 830: (Info -- Location cited in prior message) I was wondering if anyone could tell … | |
Hello friends, I am having a trouble with dosbox 0.72. I opened turbo c++ using dosbox and tried a program. But it throws an error 'unable to create hello.obj'. my program [CODE]#include<iostream.h> #include<conio.h> void main() { cout<<"hello"; }[/CODE] I gave this while opening turbo c++ in dosbox... Z:\>mount c d:\turboc3\ … | |
I have a program which i need to run with 2 input files 1 is no problem but i have no idea where to start with having it run with 2 anyone have any ideas? basically heres how it goes 1)have the program run with data01.dat 2)outputs results to output.dat … | |
How to write this problem.. a. Show the customer the different breakfast items offered by the HIFI's restaurant. b. Allow the customer to select more than one item from menu c. Calculate and print the bill to the customer Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast … | |
I need a lot of help with this program: I know this is a homework problem but I am really struggling with it. This program requires you to input information about rickshaw taxi fares. The ODUSPORTS is a student powered on-campus rickshaw transportation system. Upon departure, a ticket is created … | |
[CODE] #include<iostream> #include<fstream> #include<string> using namespace std; int main() { cout<<"Start entering your text\n Put a * to terminate\n"; ofstream fout; fout.open("1818.txt"); int i=0; char c; while((c=getchar())!='*') { fout<<c; } fout.close(); ifstream fin; fin.open("1818.txt"); int word=1; int line=0; int vowels=0; while(fin) { fin.get(c); if(c==' ') word++; else if(c=='\n') line++; else … | |
| error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::ifstream' 1> C:\Program Files\Microsoft Visual Studio 9.0\VC\include\string(527) : see declaration of 'std::getline' [CODE]void read() { Inventory items[100]; string line; int i=0; ifstream inventdata; inventdata.open("Inventory.dat", ios::in); if( !inventdata ) { cout << "ERROR: Unable to … |
so cplusplus.com is losing my connection and won't email back yada yada, so untill thats resolved I'm transferring my learning to this site, now for the program. any way its just a simple "choose the math operation program" then it performs that operation, but I wanted to add a part … | |
Hi all, I kind of new in C++ and my assignment require me to do some encryption on data. Found the AES file online can anyhow guide me how to use it ? Because when i compile the test.cpp it keep giving me exception not match error. And btw how … | |
The question is: A file contains a list of names in the form: Jones, Frederick M Brennan, Claire Your program should alphabetize the list. Use the C++ string class. Also, extract names from the input stream with getline(). What i know so far: main() should declare a char array and … | |
Hi, I am writing this template Array class. I am trying out some different functions, anything I can think of to implement. I have written an Add function as follows: [CODE] /**Add function - adds an element at the top of the stack**/ //creates new Array 1 larger //sets position … | |
I'm a beginner c++ programmer. I use Win XP and CodeBlocks. I'm trying to make a pong game, I already have the controls programmed, but I need a method to do the following: Check for user input, if they don't input for x milliseconds, then continue with the loop so … | |
ok so what does this do.. 1.) read the text file(most likely a c++ code in text form) line by line and display it line by line... 2.) (as the title says) check for syntax errors. ( only minor ones like missing ";" or a lack of closing braces) soooo..... … | |
I am currently working on a Win32 program where I have a picture. Depending where they click on the picture, something will happen.I just loaded the picture on the window, but how do I make it so that my program can tell when a certain area on the picture on … | |
im curious as to if there is a benefit to the coder and/or reader in assigning a variable name in a class functions prototype...for example class book { private: //blah public: book( int, string, double); } vs. class book { private: //blah public: book( int data1, string name1, double data2); … | |
I'm trying to read this input from a text file but whenever I try to output it, it shows up as 00000. Input: IBM 100 93.2 98.6 MER 200 67.2 43.89 QQQ 300 78.9 70.0 C 200 35.78 50.02 CSCO 400 45.67 57.23 This is what I have so far: … | |
How can you do this in c++? | |
The program asks the user to provide from 1 to 6, inclusive, numbers between 1 and 59, inclusive, as their lotto numbers. The lotto program will then use the random number generator to provide the same number of numbers in the same range. Check to see how many of the … | |
I am working on a program that will scan the screen for a certain color. I made a code that will scan, but it is too slow. Is there anything else i can use instead of GetPixel()? Or is any other way I can speed this up. If it helps … |
The End.