49,761 Topics
| |
[CODE]#include <cstdlib> #include <iostream> #include "ccc_time.h" using namespace std; int main(int argc, char *argv[]) { double r[10]; Time now; int seed=now.seconds_from(Time(0,0,0)); srand(seed); for (int i=1; i<=10; i++) { r[i]=(rand()%10+1); cout << r[i] << endl; } system("PAUSE"); return EXIT_SUCCESS; } [/CODE] This generates numbers between 1 and 10. What do I … | |
I know that arrays have to be given a size when using them, so I tried to, but this piece of code doesn't seem to want to be accepted by the compiler. data is a std::vector<char> so i tried using the .size() function to use the size of the vector … | |
In a statistics book there is an algorithm of generating pseudo-random numbers with uniform distribution [0,1]. It says: I. Enter an initial variable X positive integer. II. Multiply X by variable "a", which should be at least 5 digits long. III. Divide a*X by value p (positive integer). IV. Take … | |
[CODE]Table table; table.UpdateSeats(false, false, false, false, false, false); std::list<bool>::iterator Test = table.GetSeats(); std::cout << "The current status of seats: "; for (int i = 0; i < 6; ++i) { std::cout << " " << *Test; ++Test; std::cout << std::endl; }[/CODE] No compiler errors or warnings, just a Debug Assertion … | |
I have the following code: [CODE] #include "stdafx.h" #include <windows.h> #include <GdiPlus.h> #pragma comment( lib, "gdiplus" ) int GetEncoderClsid(const WCHAR* format, CLSID* pClsid); void gdiscreen(); void gdiscreen() { using namespace Gdiplus; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); { HDC scrdc, memdc; HBITMAP membit; scrdc = ::GetDC(0); int Height = … | |
TIMERS.h: [CODE]#include "includes.h" class servtime { public: int sec() { int sec; time_t rawtime; tm * timeinfo; time(&rawtime); timeinfo=localtime(&rawtime); sec=timeinfo->tm_sec; return sec; } int mint() { int min; time_t rawtime; tm * timeinfo; time(&rawtime); timeinfo=localtime(&rawtime); min=timeinfo->tm_min; return min; } int hour() { int hour; time_t rawtime; tm * timeinfo; time(&rawtime); … | |
Hi there, Im a structural engineer (so excuse my limited knowledge of C++ and programming in general) and write analysis programs using microsoft visual studio. I've developed a few programs that run within VS but am wondering how I would go about making these stand alone apps/programs anyone could use … | |
Hi all, I want to make my own widgets in c++, but don't know where to start. I didn't find any examples, tutorials,... on google. I know there are some toolkits like qt, gtk+, wxwidgets, and i've used them already, but i want to make some myself. Qt says to … | |
Hello, I am trying to create a program to read text from clipboard. It works great, but when I copy a file the program crashes. I am trying to make it to ignore any files and only output text. My code so far is the following: [CODE]#include "stdafx.h" #include <iostream> … | |
Hello, I am trying to upload a file via ftp using the library curl. Of course I looked [URL="http://curl.haxx.se/libcurl/c/example.html"]here[/URL] but the exemples don't say how to do this using usarname and password. Aslo the code is in C and if I compile it in C++ I am getting: [CODE]error C2664: … | |
this was probably a bad idea to begin with since i've never messed with multithreading or the sapi... but i got the sapi working on its own, but when I put it in its own thread it wont speak anymore. I've tried over and over and over.... i'm not sure … | |
| Hello, I have a dll that I wrote and a driver program to call that dll. Both the programs were written in VC++ 2008 express edition. The program takes in 2 strings as a command line argument and passes it to the dll which prints the 2 strings in the … |
[CODE] time_t rawtime; struct tm * timeinfo; char sec [80]; char min [80]; char hour [80]; char year[80]; char month[80]; char day[80]; time ( &rawtime ); timeinfo = localtime ( &rawtime ); string timetest; timetest= strftime (sec,80,"%S",timeinfo); timetest= strftime (min,80,"%M",timeinfo); timetest= strftime (hour,80,"%H",timeinfo); timetest= strftime (year,80,"%Y",timeinfo); timetest= strftime (month,80,"%m",timeinfo); timetest= … | |
Hello, Is it possible to use ctypes for this? I tried a sample code from net but it is not working. [CODE]from ctypes import cdll myDll = ctypes.LoadLibrary('C++dll.dll') mydll.testString()[/CODE] Can u tell me how to load a C++ dll and call the functions from python? | |
Hello All, I've been learning C++ recently and my question pertains to inheritance. What I have is code like this: [CODE=cpp] class shape { public: virtual void print_type()=0; double delta() //acts the same on all shapes }; class sphere : public shape { public: void print_type() { cout << "this … | |
Help random numbers rand() returns same numbers I am trying to make a blackjack program which uses srand() with time as seed to determine random number of card between 1-10. Two problems, one is that the first three returned numbers are always similar and one digit or so more than … | |
This is a simple game that I am bringing to a close. It is called Slash and Smash. The goal is to defeat the last opponent, who is a champion of the arena. In the game player can use potions for health and energy,go to sleep, heal up, eat and … | |
I need to know the syntax of how i can read a string from a file without using char array or char variable. i want to declare a variable of string type but its giving error . I have include <cstring>,<ctype> libraries. int main() { string s1; ifstream fin fin.open("myfile.txt"); … | |
Hello Outline of the problem: Files: 1. a.cpp, a.h, atest.cpp 2. b.cpp, b.h - file a.cpp is compiled to liba.so - file b.cpp is compiled to libb.so - function af01 defined in a.cpp calls the function bf01 defined in b.cpp - file atest.cpp is compiled to executable program, which calls … | |
Hi, me an my friend are creating a program that requires locating files, which requires knowing the file path. We came across functions to find the user name of the current person logged into windows, and to find all the logical drives on the target computer. We need help passing … | |
Hi, I'm having trouble with the following code and any help is greatly appreciated. [CODE]/*########################################################################## ### The problem should prompt the operator to enter the number of competitors, followed by the scores awarded to each by the 5 judges. Scores can range from 0.0 to 6.0 in increments of 0.1. … | |
When I initialize my grid array I have no problem initializing it changing my row values like so grid[0][0] = 0; grid[1][0] = 0; grid[2][0] = 0; grid[3][0] = 0; ...but when I do this "grid[0][1] = 0;" or "grid[0][2] = 0;" and all the way up to 8 the … | |
[CODE] int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst;[/CODE] but how can i call it , i mean like if i wanna cout << tm_sec ; how can i do that!! :confused: | |
[CODE] #include <iostream> #include <fstream> using namespace std; void LOGMSG(string test) { ofstream log; log.open("text.txt"); log << test.c_str(); } int main() { LOGMSG("this is a test"); LOGMSG("this is a test2"); LOGMSG("this is a test3"); } [/CODE] but it's only writes the last line i mean the last time i called … | |
I am getting 2 different compiler errors of the following: AoE2Wide.cpp(1089): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'AoE2Wide::DrsItem' (or there is no acceptable conversion) 1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(599): could be 'std::vector<_Ty> &std::vector<_Ty>::operator =(std::vector<_Ty> &&)' 1> with 1> [ … | |
Hi, I have this struct: [CODE]typedef struct empresa { char nome_empresa [20]; MORADA morada_empresa; int nif; int telefone; int anocriacao; char cae [20]; ESTAGIARIO estagiarios [MAX_EST]; int num_est; } EMPRESA;[/CODE] And an array of this struct: [CODE]EMPRESA empresas [MAX_EMP];[/CODE] My problem is that when i try to, manually assign values … | |
Is it possible to print the .00 in the Part_Price[] so it would say 11.00 instead of 11. [CODE]#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; double Part_Code[10]={1,2,3,4,5,6,7,8,9,10}; double Part_Number[10]={101,202,303,404,505,606,707,808,909,1010}; double Part_Price[10]={5.00,4.00,6.00,8.00,10.00,11.00,15.00,20.00,3.50,12.50,}; double Number_OnHand[10]={20,15,10,50,13,5,9,7,15,6}; int main(int nNumberofArgs, char* pszArgs[]) { int Pnumb,i; cout << "Enter Part Code '1' thru … | |
I've searched all over for an answer to this, including this forum, so sorry if I missed something, anyway, I'd like to get a numerical code from extended characters like ß or ü and so on. I don't use them very much myself, as I'm a native English language user! … | |
The first day of class today we had an (optional) diagnostic programming assignment. The problem is: to take an input file with a sentence in it, and make all letters except the first one lowercase, make the first letter uppercase, and remove any extra spaces and line breaks. After working … | |
hello, i have a dev c++ compiler and i want to install the allegro on it...... i tried few methods but they didnt work out.... can anyone tell me how to do it,plz? |
The End.