C++ :: Wrapping Native API Takes Ridiculous Amount Of Time
May 9, 2014
Just wrapping WIN32 is a pain. But I'm learning a shit load about windows in doing so. Designing good software is hard. Even though I can create any gui component I want. I'd have to spend the time to make it synchronous, asnychronous, and learn how to bubble up messages from the windows procedure. Then there is the ordering of components.I'm convinced People who actually used the native apis to make large softwares before autocompletion were INSANE!
View 13 Replies
ADVERTISEMENT
Oct 25, 2014
I'm trying to make a very simple reaction game where a random number flickers on the screen for a fraction of a second and the user has to then enter the number before another comes on the screen after a random amount of time. However I dont know how i would make it so that the user cannot enter anything after a certain amount of time has passed, below is my code?
Also FYI, clock_start is at 5100 because by the time the program actually gets to scanning in the first number the time is at an absolute minimum of 5050 milliseconds however obviously this is an impossible number to reach due to processing, my machine clocks in at 5080.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
int main(void){
[Code]...
View 6 Replies
View Related
Aug 22, 2013
the program has to accept a keypress. It should wait for some fixed amount of time. If a key is pressed within this time, the program should call a function. If a key is not pressed in this time limit the program should continue its normal execution. The problem with getch() is that it essentially requires you to press a key and it does not allow other instructions to execute until the key is pressed.
View 3 Replies
View Related
Mar 9, 2013
Say I want to leave a program running and it stops when I press F9 for instance, I'm looking for something like (and note this is just a generalization).
#include blah
using namespace std;
/wait 2 hours
/key.press = F9
return 0;
View 5 Replies
View Related
Jan 20, 2013
I am writing a C++ program which takes date & time input from the user. This is then parsed into a struct such as:
struct time
{
short year;
short month;
short day;
short hour;
short min;
};
My question is: how can I convert such a struct into a time_t object, which is an unsigned long giving the time as the number of seconds elapsed since the epoch Jan 1st 1970, 00:00, as set out in time.h.
I am wondering if this can be achieved using the standard library, or whether I just need to write a function to perform the appropriate arithmetic.
View 2 Replies
View Related
Jan 26, 2011
I'm currently working on a project that utilitzes a Caesar Cipher. Basically, it reads input from a file and then, depending upon the input file, requires encrypting or decrypting. The cipher used to encrypt/decrypt simply adds/subtracts an integer from each character in the input file. All input is lowercase alphabetic characters (ASCII 97-122). My problem is trying to figure out how to wrap the ciphered characters, e.g., if the cipher require a shift of +5 and the character read was 'x', a shift of +5 to the right would produce 'c' (beginning with 'x' and counting up 5 letters: 'y', 'z', 'a', 'b', 'c').
I've written some crude and cumbersome loops that will work, but there has to be a better way. It is my understanding that it can be done using the modulus operation, %, but I cannot figure out how. I spent several hours trying to figure out the modulus approach, but no luck.
View 6 Replies
View Related
Feb 25, 2015
I'm trying to make a program that allows the user to input an arbitrary amount of numbers and finding the largest of all the inputs but I keep having problems with the output.
javascript:tx('
#include <iostream>
using namespace std;
//******************************************
//CLASS COMPARATOR
//******************************************
class comparator {
public:
comparator();
[Code] .....
And regardless of what numbers I enter, I always get the output of 10. Also I got the EOF idea from my textbook so if there is a better way of doing this I'd like to hear it. I don't know any clear ways that looks nice to end the while loop when the user doesn't have any more numbers to enter.
View 3 Replies
View Related
Mar 24, 2014
I am actually working on IEEE Arithmetic especially the IEEE 754 specification where the IEEE double only have 53 bits of precision. I am working on Z/nZ matrix multiplication that works on 53 bits specs. How to write a matrix multiplication algorithm that works well on 53 bits IEEE precision standard.
View 5 Replies
View Related
Mar 10, 2015
This is a round robin execution. with gantt chart. arrival time and burst time. I think there is an error in my formula to get the right answer,i cant resolve it but my program is running. What is the code or the right formula??
#include<stdio.h>
int main(){
int i,j=0,n,time,remain,flag=0,ts;
int sum_wait=0,sum_turnaround=0,at[10],bt[10],rt[10];
int ganttP[50],ganttStartTime[50];
printf("Enter no of Processes : ");
scanf("%d",&n);
remain=n;
[Code] ....
View 2 Replies
View Related
Mar 6, 2013
I bet there's a simple function that can return the amount of RAM available on the computer, or perhaps the total RAM on the chip.
Basically I want a way of making sure my program never tries to allocate memory when it can't... I know that Windows should stop this happening anyway but I want to make sure the program can take care of certain things if it happens.
View 3 Replies
View Related
May 1, 2013
So I'm trying to learn how to use time for time based movement and what not. I did this only knowing the command time(&variable)
time_t timer;
int I, X;
void main() {
time(&timer);
X=timer;
while(I==5) {
[Code] ......
There's probably some other better way to do it... Obviously but for now I see it as putting current time in X.
start while
take in time constantly until I is 5
constantly asking is time>X(preset time 5 seconds ahead)
if it is
display message and add one to I
Why doesn't this display my message after 5 seconds?
View 1 Replies
View Related
Jan 7, 2014
Write a c++ function that takes int as an argument and doubles it.the function does not return a value.
View 5 Replies
View Related
Oct 4, 2013
I keep getting this error in my code. I believe it is because to use pow(x,y) both x and y have to be double, but how do i put that into my formula under calculations?
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
int main() {
// Declaration section: Declaring all variables.
[Code] ....
View 4 Replies
View Related
Feb 25, 2015
I want define Variable that has all amount of between two integer example: 2-4
View 1 Replies
View Related
Feb 23, 2015
I just want to call the function : outputboo(), but I dont know how
Code: /*Enthusiastic
Pessimism
desensitize
uniqueness
*/
#include <stdio.h>
#include <string.h>
struct Books{
char title[50];
char author[50];
[Code]...
View 2 Replies
View Related
Feb 23, 2013
I'm writing an addition and subtraction calculator that takes input as: 5+6-3+2. You should be able to add or sub as many numbers as you want. I want the while loop to stop when the user hits enter. I put the getchar() function to catch the and break the loop but it is also swallowing the '-' sign, which I want to use to subtract and is instead adding the numbers with "sum+=number". How can I get around that?
Code:
#include <stdio.h>
int main(int argc, char *argv[]){
int number, sum = 0;
[Code]....
View 3 Replies
View Related
Dec 7, 2013
Write a c function which takes a string(as a character array, null terminated) and reverses it. it doesn't print the reversed string -- it modifies the given string so that it is reversed.
Code:
void reverse(char array[]) {
char tmp;
int i, j;
for(i=0;i<strlen(array); i++){
for(j=strlen(array)-1;j>=0;j--) {
tmp = array[i];
array[i] = array[j];
array[j] = tmp;
} } }
how come this doesn't work?
View 2 Replies
View Related
Nov 25, 2014
I have to make a program that takes several numbers into an array into a function, and send them back into the main function multiplied by 1.13. This is what I have so far:
#include <iostream>
using namespace std;
void connell(int&n[20])
main() {
int num[20];
[Code] ...
I do not know how to get numbers from an array from a main program to a function.
View 2 Replies
View Related
Jan 22, 2014
It is possible to change the number of operands an operator takes?
I think it is false. Am I right?
View 1 Replies
View Related
Nov 28, 2013
Write a C/C++ program that reads a boolean expression in sum-of-products form and generates the sum-of-minterms form (canonical form). Use single letter to represent variables. The following symbols will be used to represent operators: NOT: ~, AND: *, OR: +. Other operators won't be used.
Examples of execution:
number of variables: 2
SOP expression: ~A+B
output: ~A*~B + ~A*B + A*B
number of variables: 3
SOP expression: x*y*z + ~x*~y + y*~z
output: x*y*z + ~x*~y*z + ~x*~y*~z + x*y*~z + ~x*y*~z
View 3 Replies
View Related
Dec 17, 2014
I have a stored procedure, which I cannot change (it is used by older programs). It is passed an int of 15 and then an ID is generated and written to a database table. The created ID is then suppose to be selected and returned.
The INSERT does not seem to be working. I'm not getting the created ID value from my code, I am getting the value I passed to the procedure when I get to this
line of code "sessionID = sessionProcedureID.Value.ToString()";.
Below the stored procedure and my code.
/***************Stored Procedure***********************/
USE [testDataBase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[MakeValue]
[Code] .....
View 14 Replies
View Related
Feb 10, 2014
I am having trouble creating a new User from my User Class. The error I am recieving:
Error3'HospitalSystemBL.User' does not contain a constructor that takes 2 argumentsC:UsersStudentdocumentsvisual studio 2010ProjectsHospitalSystemHospitalSystemLogin.aspx.cs2131HospitalSystem
In my User class, I have two constructors. Default and an overloaded constructor.
//default constructor
public User() {
}
//overloaded
public User(long UserName, string Password)
[Code] ....
I am trying to create my user in my Login class. Why is the error saying "does not contain a constructor that takes 2 arguments" when I have a constructor (above), User passing two arguments: UserName and Password? Here is my code for the login:
protected void btnLogin_Click(object sender, EventArgs e) {
try {
int Userid = Convert.ToInt32(txtUser.Text);
string password = txtPassword.Text;
[Code] ....
View 11 Replies
View Related
Oct 25, 2013
you have been tasked to write a program that takes two complex number and return their sum.However the + operator will not worl with complex numbers and you figure you need to verload the + and the assignment opeartor=.Ypu have come across the program [URL]
implement it and the client code to see it rune for the following complex numbers:
c1=3.0-4i,c2=8+4i
i have 3 files,driver.cpp,Complexnumber.cpp and complexNumber.h
complex.cpp is as follows
#include <iostream>
using namespace std;
class ComplexNumber {
private:
double real;
double image;
[code]....
View 4 Replies
View Related
Sep 29, 2014
How to write a code that will let me input how many variables I want.
Write a program that will enable you to enter a certain amount of values
Eg. 4
And then add the corresponding integers. Ex.
Choice: 4 12 34 56 78
The sum of the integers is: 180.
View 4 Replies
View Related
Mar 8, 2014
I’m writing an application for raw image processing but I cannot allocate the necessary block of memory, the following simple code gives me an allocation error.
double (*test)[4];
int block = 32747520;
test = new double[block][4];
off course with smaller block size (i.e. int block = 327475;) it works fine. Is there an allocation limit? How it is possible to deal with big blocks of memory?
View 2 Replies
View Related
Aug 22, 2014
Say I want to exhaust all the possible combinations of 10 variables to find all the solutions to an equation with 10 variables.
I could write out 10 'for' loops, but it would take a lot of space in the code and of course would take a lot of time. Another reason why I want to know this is because it could possible allow me to change the amount of for loops just by changing a number.
I.e., how can I contract the following code into a simple, short form?
for (a[0]=0;a[0]<=9;a[0]++)
for (a[1]=0;a[1]<=9;a[1]++)
for (a[2]=0;a[2]<=9;a[2]++)
for (a[3]=0;a[3]<=9;a[3]++)
for (a[4]=0;a[4]<=9;a[4]++)
for (a[5]=0;a[5]<=9;a[5]++)
for (a[6]=0;a[6]<=9;a[6]++)
for (a[7]=0;a[7]<=9;a[7]++)
for (a[8]=0;a[8]<=9;a[8]++)
for (a[9]=0;a[9]<=9;a[9]++)
if (...)
cout << ... << endl;
View 9 Replies
View Related