49,761 Topics
| |
Hi there. I am trying to create a class rectangle. It should have data members length and width of type float (which should default to 1). The class should have member functions that calc. area() and perimeter() and also separate get() and set() functions for length and width. These should … | |
[code=c++]while(!infile2.eof()) { size_t found; string temp2, store, wordtobold; string command1 ("bold"); size_t prev_pos = 0, pos = 0; getline(infile2, temp2); store += temp2; found=store.find(command1); if (found!=string::npos) wordtobold = store.substr (found+4); while( (pos = wordtobold.find(' ', pos)) != string::npos ) { string wordtotag( wordtobold.substr(prev_pos, pos-prev_pos) ); cout << wordtotag; prev_pos = … | |
Hi i was wondering if someone could tell if i am anywhere close to being on the right track. I have to create a program which adds, subtracts, multiplies, and divides fractions. I really am trying to get a grip on learning this stuff, so anyone who could give some … | |
I wonder if anyone can point out the source of my error. I am using the SDK for commercial software which _requires_ that I build etc in Visual Studio 2008. I confess that my C++ is rusty at best and that I don't understand a lot about using Visual Studio. … | |
Hi all, I have this string "May 19, 2009 15:39:41.606809000" , i need to get the seconds into a double variable. My code is like this: [CODE]double sec; string seconds = str.substr(19,10); istringstream(seconds) >> sec; [/CODE] The thing is that seconds = 41.6068090 , but sec = 41.6068 Why doesn't … | |
so I'm writing a binary search tree and a (so far very short) program taht uses it. Here's the code as it is (excluding any functions it doesn't actually use yet) main.cc: [CODE=c++]#include <ctime> #include <cstdlib> #include <iostream> #include "bintree.h" using namespace std; int main(){ double aipls[500]; bst<int> k; int … | |
Hi there, I have a question about header files/source files in Visual C++ (I use visual c++ 2005 express). I used to put all my code in one single .cpp file but now I have a test program (done by my tutor at Uni) which has 3 files: 2 .cpp … | |
Hi everybody, I bought the book "Deitel C++ How to Program, edition 5", and i am doing the exercises of the chapter 4, the exercise 4.28 ask you to write a program that print the following figure: [ICODE]* * * * * * * * * * * * * … | |
So I've implemented the binary search tree but i get an error from the insertion function this is my code: [CODE]#include<iostream> #include<stdlib.h> #include<malloc.h> using namespace std; struct NOD{ int inf; struct NOD *left; struct NOD *right; }; NOD *root; bool Erase(int nr); void Insertion(int nr); int Search(NOD* node,int target); void … | |
I am developing an application using Win32 GetOpenFileName win32 API. When the window opened even if I click cancel memory usage incredibly increases from 2 mb to 8 mb. What could be the reason of this behaviour? Thanks in advance. | |
hey frnz i need 2 make a c++ project ...but i dunno wat 2 make im so confused help me out..i need a guidline | |
This code has errors [CODE]#include <iostream> void main() { int var [10]; for (I=0; I<5; I++) cout << var(i); }[/CODE] Now what I have come up with is this to correct the errors that I see. [CODE]#include <iostream> using namespace std; void main() { int var [10]; for (i=0; i<5; … | |
Hi, Friends Here is a site which has video lecturses on C and C++ which are downloadable [URL="http://freevideolectures.com/computerscience"][B][COLOR=blue]http://freevideolectures.com/computerscience[/COLOR][/B][/URL] | |
im trying to output my bfs in this manner, showing the connections rather than the individual nodes: input 0 1 1 0 1 0 0 0 1 0 0 1 0 0 1 0 output (0,1) (0,2) (2,3) rather than: 0 1 2 3 this is my code so far, … | |
Hi, I wonder how it would be possible to programatically take a screen shot (Print screen) Then second, I do wonder how I now can save this screen shot to a .BMP or .JPG file? I would be happy to learn how this is possible to do. Thank you! | |
Hi all, I have a double pointer in C as follows: [code] void foo(char * , char**); main( ) { char * inbuff = {0x10,0x20}; char * outbuff; foo(inbuff, (char **) &outbuff); } void foo(char *inbuff, char ** outbuff); { //code to manipulate inbuff and outbuff. *outbuff = (char *) … | |
So I am trying to set up Lua on Visual C++ 2008 and I keep getting this error: [B]error C3861: 'luaL_newstate': identifier not found[/B] Here is an example of my code: [CODE] #include <iostream> extern "C" { #include "lua.h" } using namespace std; int main(int argc, char* argv[]) { lua_State … | |
So basically, I have this: [CODE=C] bool getDouble ( double & value, const string & prompt); int main() { char userSelection; do { cin >> userSelection; if (userSelection == '1') { double radius; if (getDouble (radius, "Please enter a value: ")) { cout << "good"; } else { cout << … | |
Why is this not reading from the file The contents of the file [CODE] 123456 James.Watson 234567 12.Clover.Crescent Spanish.Town St.Catherine Single Standard Passprot [/CODE] [CODE] ifstream file; file.open( "guest.txt", ios::in ); if ( !file ) { cerr << "File could not be opened" << endl; exit( 1 ); } guest … | |
Hello, I am currently working on a program that is supposed to do the following: I am supposed to take a data file of 5 student names that are in the following form: lastName firstName middleName. I am supposed to convert each name to the following form: firstName middleName lastName. … | |
I need help in calculating the variance for randomly generated values (using srand(seed)). When i input 5 i should get 97359589.15265 but i am getting 1.29888e+010. I am almost positive i went wrong in the calculation of the variance but have no idea what to do in making it correct. … | |
Hi, I'm working on an overloding operator homework. I'm overloading the + = += << [] && operators to work with objects that contain int arrays that can be set to have index from x to y instead of 0 to x. I'm getting the LNK2010 & LNK1120 errors on … | |
An exercise is to write a program that shows how memory is allocated to stack variables compared to heap variables. I ran the following code. [code] #include "../../std_lib_facilities.h" int main () { char c = ' '; char ch0[10]; char *ch = new char[10]; char *init_ch = ch; cout << … | |
Im just trying to read a file to see if i did the code correctly but I keep getting this error. Any help is appreciated. [CODE]#include<stdio.h> #include<stdlib.h> #include<string.h> struct Node { char name[15]; char title[15]; int year; struct Node *next; struct Node *prev; }; typedef struct Node* Box; Box build_node(FILE … | |
So I'm writing a sorting program for my class where we're required to sort three files by Insertion Sort, Shell Sort, and Quick Sort. By the way that it works, I ended up using vectors for all the data, and I've got Everything working now, except for the shell sort. … | |
[code=c++] while( getline( infile2, temp2 ) ) { size_t prev_pos = 0, pos = 0; while( (pos = temp2.find(' ', pos)) != std::string::npos ) { string wordtobold( temp2.substr(prev_pos, pos-prev_pos) ); cout << wordtobold << '\n'; prev_pos = ++pos; } string wordtobold(temp2.substr(prev_pos, pos-prev_pos) ); // Last word cout << wordtobold << … | |
If I use a template function with T where T = itk::Image<unsigned char>::Pointer, everything is fine: [code] #include <itkImage.h> class Test { public: template <class T> void Add(T patch); }; template <class T> void Test::Add(T patch) { } int main(int, char*[]) { Test a; itk::Image<unsigned char>::Pointer image; a.Add(image); return EXIT_SUCCESS; … | |
Just started learning C++ today. I'm writing a program to keep up with school assignments. [CODE] #include <iostream> #include <stdlib.h> #include <fstream> #include <string> struct Assignment { string Period; string Title; string Page; string Date; string Instruct; }; void NewAssignment() { system("CLS"); Assignment Work; cout << "New Assignment Entry" << … | |
I'm having so much trouble with this assignment, and I was wondering if anyone would be able to help me out. Here is the assignment: This program uses the file "cities.txt", which contains over 136,000 location names in the United States. Each line of the file contains a place name … | |
Plz help, I have declared three stuct struct student { CString Struct_Name; CString Struct_RollNo; }; struct Division_struct { CString strDivName; CArray <student, student>arrStud ; }; struct Class_struct { CString strClassName; CArray <Division_struct, Division_struct > arrDiv ; }; ///to access class struct CArray <Class_struct,Class_struct> arrClass ; My question is how to … |
The End.