49,761 Topics

Member Avatar for
Member Avatar for XerX

[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 …

Member Avatar for MosaicFuneral
0
3K
Member Avatar for MasterGberry

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 …

Member Avatar for MasterGberry
0
124
Member Avatar for XerX

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 …

Member Avatar for mrnutty
0
4K
Member Avatar for PhysicsExpert

[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 …

Member Avatar for PhysicsExpert
0
803
Member Avatar for SpecialForce

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 = …

Member Avatar for SpecialForce
0
654
Member Avatar for Mr_PoP

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); …

Member Avatar for Mr_PoP
0
349
Member Avatar for v_janssens

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 …

Member Avatar for v_janssens
0
3K
Member Avatar for hannesvdc

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 …

Member Avatar for hannesvdc
0
1K
Member Avatar for SpecialForce

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> …

Member Avatar for Ancient Dragon
0
149
Member Avatar for SpecialForce

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: …

Member Avatar for SpecialForce
0
2K
Member Avatar for headedtomexico

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 …

Member Avatar for donaldw
0
429
Member Avatar for nalasimbha

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 …

Member Avatar for Narue
0
303
Member Avatar for Mr_PoP

[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= …

Member Avatar for Mr_PoP
0
87
Member Avatar for meensatwork

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?

Member Avatar for TrustyTony
0
1K
Member Avatar for joinerc

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 …

Member Avatar for joinerc
0
138
Member Avatar for bbman

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 …

Member Avatar for Narue
0
163
Member Avatar for Firsum

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 …

Member Avatar for jember
0
350
Member Avatar for sairakhalid

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"); …

Member Avatar for mraza1_ch
0
281
Member Avatar for ctyszkiewicz

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 …

Member Avatar for ctyszkiewicz
0
146
Member Avatar for GeekInTraining

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 …

Member Avatar for Ancient Dragon
0
232
Member Avatar for shiny27

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. …

Member Avatar for WaltP
0
101
Member Avatar for Peter_morley

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 …

Member Avatar for Peter_morley
0
219
Member Avatar for Mr_PoP

[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:

Member Avatar for Mr_PoP
0
91
Member Avatar for Mr_PoP

[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 …

Member Avatar for MasterGberry
0
494
Member Avatar for MasterGberry

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> [ …

Member Avatar for MasterGberry
0
194
Member Avatar for nomadewolf

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 …

Member Avatar for osirisgothra
0
146
Member Avatar for alonewolf23

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 …

Member Avatar for mrnutty
0
133
Member Avatar for Dorson8009

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! …

Member Avatar for Dorson8009
0
165
Member Avatar for iamthesgt

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 …

Member Avatar for mrnutty
0
217
Member Avatar for sahil1991

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?

Member Avatar for Peter_morley
0
73

The End.