C++ :: Loop Is Running Infinitely
Aug 7, 2014My program is supposed to end when both a and b are 1. Where it is wrong.
Code:
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int roll()
[Code] ....
My program is supposed to end when both a and b are 1. Where it is wrong.
Code:
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int roll()
[Code] ....
i am writing a function that takes a delimited string and splits the strings into it's respective words according to the delimeter.
1) iterate through string and store delimeter position in vector array.
2) iterate through again and use substr to split into words and store again in a vector.
I then have a dictionary file, and am comapring each values in the string with each in the dictionary, problem is that it overruns the loop and obviously gives a subscript out of range error.
Code:
#include <iostream>#include <fstream>
#include <vector>
using namespace std;
//Start with string inputString
//Find delimeters ::pos as ints and stores positions in vector <int> array
//Run though string using 'find' and seperate string by positions of char32s
//Build vector<string> array of individual words in string
//Open dictionary file and loop though testing each words in vector string array against each word in dictionary
[code]....
I ran into a problem while using while loop.T he declared and initiated local int variable works well with its specified value while running through the 1st run of a while loop. It is set zero while entering the 2nd run and the following unexpectedly. However, the variable still exits. The following is the code with problem.
Code:
#include <stdio.h>
int main(void){
const int x=6;
char c='y';
[Code]....
This program is meant as practice. However, it is not working as intended. The for loop is meant to take the argument from the user and use it as the amount of times to loop. Instead it simply outputting: . It is supposed to output i++ but does not.
Here is the code:
main.cpp:
#include <iostream>
#include <stdlib.h>
int main(int main, char* arg[], char* arg2[]) {
int iterator = atoi(arg2[0]);
std::string z = "-c";
[Code] ....
I am stuck on an exercise where i am supposed to use a loop to take user input and keep a running sum until the user enters a 0. the code i have so far is:
#include <iostream>
int main() {
using namespace std;
int num;
int total = 0;
int x;
[Code] ....
The full text of the error message is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream' . and one more thing i was wondering, is there a difference between c++ and visual c++?
Why this program keeps looping infinitely when i run it and try to put some input...
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
using namespace std;
struct Account {
[Code] ....
What I have: A basic program for infinitely looping after and testing for an active process. It has a delay system built in to make it so it is not constantly iterating.
What I need: A way to get process IDs from other Processes other than my program. With a way to use that ID to detect if that process is active on the computer or not.
Parts of my code that need changing:
/* Code for handling the process would go here */
/* Code for detecting the target would go here */
What the goal of my program is: Perform operations to terminate the process of cmd.exe when it is active on the user's computer. Then output the status of the process and the time it took to find that process to the user.
It contained functions that I needed, but I need more information on how to apply them to other processes instead of the parent of my program and its' children.
Here is the code I prewrote for this so far:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ZERO 0
#define INFINITE 1000000000000000
[Code] .....
after you have compiled a program can you run it without an IDE?
View 17 Replies View RelatedI want to know if you can run bat files from code? If so how else how can you shutdown a computer with code? OS is windows 7.
View 2 Replies View RelatedI have a COM exe which runs fine on all machines that I have used except one. On a particular machine, the COM exe does not start even after trying to execute it manually (do a double click on the file from explorer).
There are no error messages as well. what could be happening ?
I have a question, how can I check if a program is running using c++? For example
if (notepad.exe is running) {
.... ..... ....
Giving a dynamic array, we want to pass the array elements from a file. The first number in the file N gives us the array length. They follow N numbers, the actual elements of the array.
Three brothers are going to work in the shop of their father for a time. The shop is doing well and every day generates profit which the three brothers may provide. The brothers agreed that they would divide the total time in three successive parts, not necessarily equal duration, and that each one will be working in the shop during one of these parts and collects the corresponding profit on his behalf. But they want to make a deal fairly, so that one received from three more profit someone else. Specifically, they want to minimize the profit the most favored of the three will receive.
I first created a program that WORKS! with complexity O(n3).
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int sum_array(int* array, int cnt){
int res = 0;
int i;
for ( i = 0; i < cnt ; ++i)
[Code] .....
Let's assume that we have the following input:
10
1 1 8 1 1 3 4 9 5 2
The ouptut should be 15 -> A = 1 + 1 + 8 + 1 + 1 + 3 = 15 , B = 4 + 9 = 13 , C = 5 + 2 = 7.
But the ouptut is 16!
How can I reduce the complexity of my first working! C code?
I have a service A, and an application B. Service A needs to launch application B only if it's not running currently. This can be easily done in Windows by calling GetExitCodeProcess function. I cannot find an equivalent method for doing so in Linux/Mac.
So my current code says:
system("open /Users/adsmaster/client/client &"); // to launch the application from the service in a new shell
I read that on a Linux-line machine you can use $ cal to get the exit value of the recently run process but I am not sure how can get the exit value of a particular process?
I am working on a parallel processing server/client app with a multi-threaded server and several data processing clients, each their own process. I am trying to optimize some of the parameters, such as the size of the chunks that are read, processed, and output, and also some of the timeout values and such. I can track the time to finish a given task well enough, but it would be really nice to be able to track the cpu use. When CPU use is near 100% (on all cores) for the entire run, that is a good sign. I have noticed that with some combinations of parameters, CPU drops quite a bit for long stretches, which is not such a good sign. This app process large input files (2.5GB-65GB so far) and needs to be stable for long periods of time.
Other than sitting and staring at the task manager all day, is there a good way to track/log the CPU usage over runs that take many hours? I know that there are some apps like Everest that chart CPU use, but it would be nice to have something that would write to the same log file I am already using for other program output.
I need to run a program that makes a SLR Parser Table.
Here is the code :
Code to find first and follow:
saved as SLR.h
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream.h>
#define epsilon '^'
since I didn't know how to type epsilon symbol temporarily I am using ^
char prod[20][20],T[20],NT[20],c[10][10],foll[10][10],fir[10][10];
int tt,tnt,tp,a;
int follow[20][20],first[20][20];
void first_of(char);
int count(int j);
void rhs(int j);
[code]....
I am trying to do single axis solar tracker with linear actuator /rtc/ UNO. I have already done with feedback sensor.
Now Here I am trying to without feedback. Linear actuator specification: 24v , 3.2mm/sec as speed , 600mm stoke.
Desired angle calculation:
tracking start from 7am to 18PM, 11hours
Assumed degree: 7AM as -45 deg , 12.30 as 0 degree and 18 pm as 45 degree.
static float slope= 0.00227272727273;
static float intercept=- 102.272727273;
[Code] ....
How can i put time here. Coding for calculating Ton time and solve above equation. below i posted my code . I need it has to be modified little bit. i need to implement ton time actuator here.
I need function takes desired and actual angle , where actuator try to move to its actual desired position.
Code below in arduino version
Code:
double Desire_Degree;
unsigned int TS;
static float slope= 0.00227272727273;
static float intercept=- 102.272727273;
static int length;
double Actual_Degree;
[Code] .....
Code:
#include<stdio.h>
#include<process.h>
struct que
[Code].....
I have created an scientific calculator application and I have a VBS script that runs some of the files. I want to create a C program that runs that VBS script. however, a command window flashes before the application opens. So basically I need a short C (or C++) program that runs a VBS script without a command window popping up. I am on Windows 8 and my compiler is GCC/G++ under cygwin. Here is what I have now that DOES NOT work.
Code:
#include <windows.h>
int main()
{
ShellExecute( NULL, NULL, "StartUp.vbs", NULL, NULL, SW_HIDE);
return 0;
}
This code will read the running process from OS and display it (C++). Specifically, the OS here is Windows XP. The Problem(error) is in (i think) prototype. By the way, it displays following errors.
Error 1 : error LNK2019: unresolved external symbol _EnumProcesses@12 referenced in function _main
Error 2 : error LNK2019: unresolved external symbol _GetModuleBaseNameA@16 referenced in function "void __cdecl DisplayProcessNameAndID(unsigned long)" (?DisplayProcessNameAndID@@YAXK@Z)
Error 3 : error LNK2019: unresolved external symbol _EnumProcessModules@16 referenced in function "void __cdecl DisplayProcessNameAndID(unsigned long)" (?DisplayProcessNameAndID@@YAXK@Z)
Error 4 : fatal error LNK1120: 3 unresolved externals C:Documents and SettingsWindowsMy DocumentsVisual Studio 2008ProjectsaDebuga.exe
#include <afxwin.h>
#include <iostream>
#include <string.h>
#include "psapi.h"
unsigned int i;
using namespace std;
[Code] .....
I am making a timer but I want to have an input while it is running. Here is my code.
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
using namespace std;
class timer {
[Code] .....
The bolded part is my attempt at trying to put in an input while the timer is running without having the other timer functions stop.
Im making a program on eclipse(linux), and getting a bunch of errors...
type string couldn't be resolved
symbol std couldn't be resolved
unresolved inclusion <iostream>
invalid preprocessing directive #include
etc...
know whats going on? I'm pretty sure it must be something with configuration..?
I'm fairly new to PowerShell and I'm trying to run this command from my application to return the 25 newest entries in the application event log and save them to a file on my desktop. Here's the code. I get an Common Language Runtime error with no real information.
PowerShell ps = PowerShell.Create();
ps.AddCommand("Get-EventLog");
ps.AddArgument("application");
ps.AddParameter("Newest", 25);
ps.AddScript("Format-List > ~\Desktop\samplelog.txt");
ps.Invoke();
Here is the Method: [URL] ....
Here is the Error: [URL] ....
I am using Xcode to do c++ programming and I have a c++ code, with different input arguments. I want to achieve that in Xcode, I could run multiple simultaneous running of my c++ code. However, the current problem is that once one code finishes, its terminal window automatically closed and I do not have time to look at its result. Thus computer time is wasted. Is there a way to run multiple same c++ code with different arguments input?
View 6 Replies View RelatedI have a Class called 'DataManager' which contains a list of my 'DataItem' objects (this are created by an XML file).
I have also created some custom controls which, among other things, has a property to link it to a "DataItem" object.
My question is, is it possible to create an instance of my DataManager class at design time (which runs all the code as it would at run time to create all the DataItems from the XML)?
I want to do this so that I can update my DataItem property in my custom controls to use a UITypeEditor which then allows me to link to a DataItem at design time.
#include <iostream>
using namespace std;
int main() {
[Code].....
I've recently started to learn C++ and I'm using codeblocks as my IDE, but I keep getting problems with AVG free edition picking up random pieces of code as Trojans ?! I've put an example of some code that sets it off below, and the error message I get. Is there anyway I can set AVG not to trigger with any codeblocks coding I've done? I guess I could tell AVG not to trigger for that folder, if that's even possible?
Code:
#include <iostream>
using namespace std;
class MyClass{
public:
void coolSaying(){
cout << "BUST A MOVE!!" << endl;
[Code] ....
Error I get:
File name: h:DesktopC++ projectsclasses and objects 1 inDebugclasses and projects 1.exe
Threat name: Trojan horse Agent3.BMSZ
Detected on open.