C++ :: Counter That Increments Slowly And Show It In One Place?
May 9, 2013
The best I could come up with is this.
while(true){
wisdomCnt++;
_stprintf_s(szBuffer, _T("%i"), wisdomCnt/10000);
TextOut(hdc,120,10,szBuffer, _tcslen(space));
}
but the program is constantly loading and clicking anywhere causes it to stop responding. Is there a better way to do this especially in Win32 API?
View 6 Replies
ADVERTISEMENT
Jul 31, 2013
I am trying to place a counter to count in each time a new order comes in, but I am having trouble with the memory allocation part.
I allocate memory to take in names each time an order comes through, but when I print out the names, I get 0x100103ae0....
View 13 Replies
View Related
Apr 25, 2012
I've taken part the text into 1 word per line, but I can't figure out how to printf every word only once and then add (%d) in the end to show how many repetitions of that word there are.
Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main(){
char *oneword;
[Code] ....
View 3 Replies
View Related
Apr 25, 2014
Code:
char *ptr;
printf("Output: %d %d %d
",sizeof(ptr), ptr, ptr+1);
Output: 4 214734480 214734481
int *ptr;
printf("Output: %d %d %d
",sizeof(ptr), ptr, ptr+1);
Output: 4 214734480 214734484 when size of the pointer is the same "4 bytes" whether its a char pointer or a int pointer, but why a char pointer increments 1 where as int pointer increments 4.
View 6 Replies
View Related
Feb 3, 2014
I am just starting out learning C and I am using MinGW, Widnows 7, and cmd.exe.I am starting from scratch and learning very short and simple programs, like 20 lines long.After I use MinGW (gcc) to compile, the programs start up rather slowly, sometimes up to about 3-5 seconds. One with a big nested loop even took about 15 seconds to load. After they run once, the next time they run, it's instant.
Last time I learned from this book, I don't remember them starting so slowly. I use the command "gcc sample.c -o sample".It just concerns me that these tiny little programs are starting up so slowly. I'm scared it's a problem with my computer or MinGW installation. When I start making more advanced programs, I don't want them running slower than they ought to be.
View 12 Replies
View Related
Nov 5, 2014
The question is Create a counting program that counts backward from 100 to 1 in increments of 10.
#include <iostream>
using namespace std;
int main() {
int num = 1;
while (num<100) {
[Code] ....
It seems there are some errors.
View 1 Replies
View Related
Apr 3, 2014
I'm trying to make a program who increments the value of all cells of an array but when i try to compile i get this error message:
Quote
error: incompatible types when assigning to type "int[9]" from type "int *"
View 4 Replies
View Related
Apr 7, 2014
I have a problem requiring me to :
enter loan amount:
Enter interest rate:
Enter length of loan (years)
It wants me to input the minimum amount for the loan, and the minimum interest rate. and then output a table that has 5 loan amounts across the top in $10000 increments and 4 interest rates along the side in .25% increments.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main () {
double loan, interest, length, payment,ti;
//Enter loan price
[Code] .....
View 1 Replies
View Related
Jan 12, 2014
I was browsing the web looking for simple yet fun programming challenges and crossed this one. I figured out how to reverse the string in place but I want it to read "blue is house the". I approached it in two ways for the heck of it. My idea was the second one, the first one I googled. I didn't know a simple rbegin() could do that, pretty neat.
I found the question here.[URL] ....
Code:
#include <iostream>
#include <string>
int main(int argc, const char * argv[])
{
std::string phrase = "The house is blue.";
[Code] ......
View 8 Replies
View Related
Dec 9, 2013
I need function to determine where to place new element in sorted array. I want to use binary search to find index where element should be placed, when push all others.
Prototype should be something like
int WhereToPlaceElement(ElementType hash); // uses private atribute ElType** elements
I have tried my best to write, but all tries ended in inf loops and reading invalid locations of array.
View 3 Replies
View Related
Aug 25, 2014
I have an issue with my codes as according to what I created the fitness level have to appear right after I enter the time take to 3 miles. However it only appears once after repeating five times.
My codes
#include <iostream>
#include <iomanip>
#include <string>
[Code]....
View 6 Replies
View Related
Feb 1, 2015
When I drag a control onto the Xamarin studio layout the control just slides back into the toolbox again. The only way to add controls is to edit the .axml file which is not at all ideal.
I have tried re-installing all the components again multiple times and even tried out using a different computer, still no luck. How to use the mono framework on the Visual studio IDE and build the apk using Xamarin studios?
Details -
Xamarin studio 5.7
Tested on Windows 8, 8.1 and 7
View 10 Replies
View Related
Oct 27, 2013
I have created this code; it is a taxi management system. I've made a class 'List' which handle a linked list structure of the waiting taxis and waiting passengers. The class has a public int variable: waiting, which keeps track of the number of waiting taxis/passengers.
#include<iostream>
using namespace std;
class Queue{ //Class for indivdual taxis and passengers, which will be members of linked list.
public:
string id;
Queue *next;
Queue (){
[Code] .....
But when I run the code and type in a new taxi number, the code does not increment the number of taxis by one the linked list by one. I can't seem to find the problem.
BTW, in the 'int main', I've added "<< taxi_list.waiting" at the end of the line after the user inputs the new taxi registration number, so that I can see how many taxis are now on the list. This is what is being shown as zero, no matter what.
View 2 Replies
View Related
Oct 19, 2014
I have to place two asterisk triangles on top of each other BUT only using 3 for statements. I have gotten the first one:
for(int a=1;a<=10;a++) {
for(int b=1;b<=a;b++)
cout << "*";
cout << endl;
}
I need the output to look like this:
*
**
***
****
*****
******
*******
********
*********
**********
*
**
***
****
*****
******
*******
********
*********
**********
The only kicker is I can have a total of 3 nested for loop statements.
View 7 Replies
View Related
Oct 15, 2014
The question I am given is this:
Given a line of words (total character number is less than 100,
start from odd position 1,
and end with newline char "
").
Write a program to reformat it that new output is formed by each char from its odd position first, then its even position char.
View 14 Replies
View Related
Feb 3, 2014
I have a text file that ifstream opens and fills some fields with the data. I've been able to get at the file, by using the precise path, but that path would be incorrect on other computers I'll be working on the project at. So, is there default location I should drop the folder in, and route to with the path? If not which Directory listing in Visual Studio 2013 should I use so the project can find the folder?
This is how I've formatted the string for ifstream.
".DataSampleActorData.txt"
View 6 Replies
View Related
May 31, 2014
I'm trying to make a program to check if a number has decimal place, for instance: 1.34(yes), 1.0(no), 3.45(yes), 5.0(no).
Code:
#include <stdio.h>
#define LENGTH 4
int main( void ) {
int i;
float a[LENGTH];
for(i=0; i < LENGTH; i++) {
scanf("%f", &a[i]);
[Code] ...
I'm getting this output, why?
Quote
error: invalid operands of types "float" and "int" to binary "operator%"
View 3 Replies
View Related
Oct 3, 2014
This is in-place merge sort, for merge function.
LinkedListNode::LinkedListNode(int value) {
this->next = NULL;
this->value = value;
}
LinkedListNode *mergeSortedLinkedLists(LinkedListNode *firstList, LinkedListNode *secondList)
[Code] ....
View 3 Replies
View Related
May 3, 2014
Assume you want to read from a file and place the data from the file into an array. The array can hold 10 integers. The file may contain any number of integers with 1 integer per line. Fill in the missing loop test condition so that we will read from the file until either end of file occurs or the array is full. Note we are using cin to read from the file since input redirection is being used.
cin >> temp;
arrayIndex = 0;
while ( _____________________________________) {
array[arrayIndex] = temp;
arrayIndex++;
cin >> temp;
}
View 2 Replies
View Related
Apr 27, 2013
How do I add a counter for the comparisons so that it increments every time the two array value are compared?
// Session5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
const int NMAX =10;
[code].....
View 1 Replies
View Related
Jul 30, 2014
int counter won't reset to 0 when I click the start over button.
protected void startOverButton_Click(object sender, EventArgs e)
{
gameOverLabel.Visible = false;
[Code]....
View 3 Replies
View Related
Feb 17, 2015
I am not sure why this is happening but I am simply trying to make rounds with my code and have it stop when one of two things, or both, happen.
#include <iostream>
#include "Classes.h"
#include "RNG.h"
#include "select.h"
#include "Fitnesschk.h"
using namespace std;
/*Global Variables************************************/
const int column = 32;
[Code] ....
I've tried resetting and renaming all variables but I don't see any conflict. I tried declaring in different areas but no dice. The other issue I have is that fittest always returns 0 even if the function returns 1. So it infinitely loops. When I go through looking at the variables. the fittest variable never changes even if the function returns 1 and round seems to reset after reproduce is called.
Here is the supporting code.
For Fittracker:
int fittracker(person man[], int row, int column){
for (int y = 0; y < row; y++){
int fit = 0;
for (int z = 0; z < column; z++){
if (man[y].data[z] == 1){
[Code] ....
View 10 Replies
View Related
Mar 1, 2014
I am having problems figuring out how to place a list of strings from a text file into a multidimensional array that is something like words[NUM_WORDS][MAX_LEN]. I already run through the file once and count the number of words in it. I have tried a number of loops using fscanf and fgets, but I'm not sure if I am using them right -- this is my first time using them. The text file is a list of words in a dictionary, so the wordCount is about 45340.
Here is my code:
#include <stdio.h>
#include <string.h>
#define MAX_LEN 46
int main(){
int wordCount = 0;
FILE *inputFile, *outputFile;
[Code] ....
Like I said, the wordCount portion works. I added the printf statements at the end to see if anything was being saved, but it just prints two new blank lines. New to file reading and writing.
View 3 Replies
View Related
Feb 12, 2013
I have used the following code to attempt to place a binary array into and then retrieve from the Registry. I am a member of the local Administrator group. I have verified that the Registry for the app has a binary array 32 bytes in length under the key "settings" / "keyb" ab 12 cd ...
Code:
// in header
unsigned char m_key[32];
int m_nKeySize;
// in implementation
// int ctor
AfxGetApp()->GetProfileBinary(_T("settings"), _T("keyb"), (LPBYTE*)&m_key, (UINT*)&m_nKeySize);
// in OnDestroy
AfxGetApp()->WriteProfileBinary(_T("settings"), _T("keyb"), (LPBYTE)&m_key, m_nKeySize );
Here is a copy of the binary array in the Registry:
7D DE 2B 30 E7 06 12 AC 99 60 8C 26 21 FC 8E 5B 66 DB 72 9E A2 00 BE 15 E1 8B 67 31 E5 EC 8B 15
Here is the binary key retrieved from the Registry using the code above:
D0 EB 26 00 CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC
View 7 Replies
View Related
Apr 14, 2013
One that fills different char arrays the idea is to use a single char to represent a char such as 255 but if more than it then use a char array of two chars to represent the next char 00 because if only one is needed it would take less disk space than 0,255 as it would in an array.
My goal is to do this all the way up to an array that can hold 255,255,255,255 but only use the more complex array if needed Example: a char of 255 takes much less space than a char array of 4 chars so that instead of 0,0,0,255 it is written to disk as a single char whereas a char array of 200,0,0,1 would be written as a 4 byte char array. use single char to represent values from 0 to 255 use two char array to represent 0,1 to 255,255 three for 0,0,1 to 255,255,255 and four for 0,0,0,1 to 255,255,255,255
View 3 Replies
View Related
Jun 18, 2013
I am trying to make a program which reads a text file, separates the strings into words, then finally saving and counting each different word.
When I comment out the code where it is supposed to search for the same word in the table, the program doesn't work.Am I doing something wrong with strcmp or the loop? The 'break' just exits out of that 'for' loop right?
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define WORD_MAX 500
#define LIST_MAX 500
int main(){
int i, j, find;
[Code]...
View 6 Replies
View Related