C++ :: Why System Cannot Terminate Itself
Nov 18, 2014#include <iostream>
#include <string>
using namespace std;
[Code].....
This is my code, when my pintrials = 0, my system cannot terminate but go through the option menu below.
#include <iostream>
#include <string>
using namespace std;
[Code].....
This is my code, when my pintrials = 0, my system cannot terminate but go through the option menu below.
How can I terminate a function?
View 3 Replies View Related"Allow the user to enter an integer, between 1 to 9 only. You may use the value ‘0’ to terminate the program. Then display the output as follows:
Sample Run 1
Enter an integer (1-9):4
1
121
12321
1234321
Sample Run 2
Enter an integer (1-9): 20
You have entered an invalid entry, please try again.
Enter an integer (1-9): 0
(Try to use remark to explain function and process area)
how to use EOF to terminate inputting data
View 1 Replies View RelatedI am new to C++ and wrote some code here that is not working how I want it to:
Code:
int main() {
vector<string> distinct;
string parag;
typedef vector<string>::size_type vec_sz;
vec_sz size = distinct.size();
[Code] ....
Basically, if I run it, it takes a string, stores it in a vector string, and then outputs it to the screen as I hit enter. But then it waits for another string to be entered. How can I stop it waiting for new input after I hit enter? I tried comparing parag with and terminating there, but I am getting compiler error. I am using code::blocks.
creating a program using while that terminates the loop when two intergers any two between 1 to 100 are equal with each other
View 2 Replies View RelatedI've stored a binary pattern in what is interpreted as an unsigned short.
unsigned short byte_one = 128;
I've done some bitwise manipulation and want to store it back into an array, however, it needs to be null-terminated.
buf[1] = byte_one;
How do I null-terminate this?
this application has requested the runtime to terminate it in an unusual way. contact the application support team for more information!!!
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
[code].....
I have a thread with a while(1) loop in it. When the user push the stop button I would like that thread to end.
I thought about creating a bool and checking its value periodically in the thread and when I push the stop button I change the value of the bool for that the thread breaks out of the loop and finishes.
Code:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
int main(void) {
int i;
char *str;
int len = 1;
[Code]...
I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.
#include <iostream>
using namespace std;
int Max(int x);
int main() {
int x;
[Code] ....
So, as far as I can tell, this code should run a system command from the C++ program:
system("ping 192.168.1.2 /t /l 32768");
However, I just keep getting a "system Was not declared in this scope" error message. Is there something wrong with this?
I am working on a project that is like a banking system and needs to include making a withdrawal, transaction, deposit, query, and transaction.
Code:
#include <stdio.h>
//#define true
//#define false
//assume there is money in the account. $10,000
void deposit(){
[Code] ....
I just started my task with Ordering system. what should I use if I'm going to ask the user if he wants to exit the system, he will press(zero)0 to exit the program and press Y(uppercase or lowercase) to continue?
View 1 Replies View RelatedHere's the objective of the program: "Instead of using ABCDEFGHIJ to order letters use DCBAJIHGF go order. The program should determine which 4-letter word is larger of two based on this new ordering system."
Not even sure how to start with this problem , how would I go about defining my own ordering system?
So I know that I can call a program by system("prog.exe"), but what do I add in when I want to pass a parameter?
View 2 Replies View RelatedComputerized GPA Evaluation System using Array
You are required develop a computerized GPA evaluation system of your class using array. The basic idea is to calculate the GPA (Grade Point Average) of each subject and then calculate the GPA of whole semester of all the students of the class and on the basis of that GPA calculate the grade and remarks of each student of the class. Suppose that the total students of the class are 50. Your system must also provide the facility of the following:
1.Searching a student result according to his/her roll number.
2.Updating the obtained marks of the students in case of any mistake in entering marks.
3.Display the result of student who is the topper of the class
4.Display the result of the student who got minimum CGPA out of the class.
5.Display how many number of students got greater than or equal to 3.0 CGPA.
6.Display how many number of students got greater than or equal to 2.00CGPA and less than 3.00.
7.Display the total number of students who got A grade in the semester.
8.Display the total number of students who got B grade in the semester.
9.Display the total number of students who got C grade in the semester.
10.Display the total number of students who got F grade in the semester.
Detailed Description:
You are required to take the student’s marks for four subjects (Programming fundamentals, Calculus, English and Computing) as input from the user at runtime. After that calculate the GPA of each subject and the whole semester. Assume that total marks of a subject are 100 and each subject is of 3 credit hours except programming fundamentals. Programming fundamentals subject has 4 credit hours.
Complete Assessment system is given below in the table:
S.#Percentage (%)GradeGPARemarks
185-100A4Excellent
280-84A-3.75Very Good
375-79B+3.50Good
470-74B3.0Satisfactory
565-69C+2.50Above Average
660-64C2.0Average
755-59D+1.50Pass
850-54D1.0Just Pass
9Below 50F0Fail
Table: Assessment Scheme
•Percentage of a subject = (obtained marks / total marks) * 100. Percentage works to find the grade of the student.
•GPA of whole semester = multiply GPA of each subject according to the percentage of obtained marks by the number of credit hours for that course, sum up the GPA of all the subjects, and then divide this sum by the total number of credit hours taken in semester.
For example suppose the GPA in subject X is 2.5, in subject Y 2.6, and in subject Z is 3. Assuming that each subject is of 3 credit hours then GPA of whole semester will be calculated as:
GPA= (3 * (2.5 + 2.6 + 3)) / 9
GPA= 2.7
On the basis of Semester GPA, you have to give grade and remarks to the student. You have to study the above table for other types of remarks according to grade.
•If a student has less than 50 marks in a subject, a message should display that “you have to repeat this subject “.
Code:
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
main() {
char a,b,c,d;
[Code] .....
I just purchased Visual C++ 2010 Ultimate, to start my coding experience. Whenever I try to debug, it gives me this error:
The system cannot find the file specified
It can't find the .exe file, I even Googled it, and tried a few things, without any luck.
I code login form. In the textbox I want to clear if there are some text or close form if there's nothing. The problem is System beep sound occured when the text is cleared. Here's my code
private void tbPassword_TextChanged(object sender, EventArgs e)
{
string _enteredPassword;
while (tbPassword.TextLength == 8)
[Code]....
I wanted create a Reminder Systems for my Project
So Scenario is like this,A Gym has owned a Software to maintain record of employee and customer, everything is ready now only reminder system is to be made. Reminder system is like for example if customer comes to gym and inquires about plan and fees and says call back him at so and so time, so receptionist will require reminder system to alert him at the time given by customer for call back.
What i have done
1.Created a Listview to show reminder list, and created two button ADD reminder and DELETE reminder When reminder is added following things are added in Reminder table in Database
i.ID
ii.Title
iii.Message
iv.Time
v.Date
2.when i display the reminder table in reminder listview, the order will be in (Date, time)asecnding order.
---Till here everything is done---
Now i am confused here, lets take example The first Reminder in Listview is around 3.00 clock, when the time is reached i want to show message that "call back this customer".
So to do this i was thinking of using timer and on each tick compare Current time with Reminder time, if equals display message, but this method is inefficient it can freeze my UI.
The Alternate way i was thinking to run this timer inside Background worker as it would create a different thread there will be no issue with my application.
I can't debug anything and get an error whenever I try. Being able to release a program to run it works sometimes, but it's hit or miss. I've created a very simple program to show the problem. The error on the screen is a result of me trying to debug, but I actually received the same error when trying to release as well.
View 6 Replies View RelatedI need to take the system time and turn it into this format: 03:20 PM, Tuesday March 17, 2015. I am suppose to use 3 enumerators for the day of the week, the month, and AM or PM. I am having a lot of trouble with converting the system time to year, month, day, hour and minute. I also know there are a lot of functions that would make this more than simple, but I have to do the calculations and use enumerators. Here is what I have so far:
#include "stdafx.h"
#include <ctime>
#include <iostream>
#include <time.h>
using namespace std;
enum Days{SUN, MON, TUES, WEDS, THURS, FRI, SAT };
enum Months{JAN,FEB,MAR,APR,MAY,JUNE,JULY,AUG,SEPT,OCT,NOV,DEC};
enum Time{AM,PM};
[Code] ....
I need a short C++ code for reboot system(only c++)
can I do it?
What I want to do is abstract and model a device (more specifically in this case, an IMU) in an embedded system.
Now, there are a couple of gotchas:
- It is basically a framework, which means that it should work with any device, any platform and any bus.
- It is an embedded system, so power consumption and memory consumption must be reduced. It is not a PC.
- It cannot be too complex, because I fear that will just make people scrap it and rewrite it from scratch :P
- It should aim for as little code as possible to write the whole model, of course. Adding 100 lines of code for each register would be a bummer.
That said, I must also model the current system, which means that the current platform, the current bus (which is I2C) and the specific IMU model (I have a datasheet).
So the model I am thinking of currently is this:
First, I have a platform. It will know what bus a device is connected on and contains the buses (or specifically, the instances of the buses). It consists of a specific class for each platform and a base. Here are the two I have now:
Code:
namespace Sensors
{
template<typename Platform_t> class GPS;
}
namespace Platforms
{
class RaspberryPi: public PlatformBase
[Code]....
Currently I am making the assumption that all platforms will have an I2c bus and UART bus, but I'm not sure about that. We have only one platform ATM, though, so for now this holds. I'm guessing I might have to move it to the specific platforms later and get rid of PlatformBase.GetI2CBus is a problematic one related to registers, but I'll get back to that.
UART is simple to model since it's just a block read and write, so:
Code:
namespace Buses
{
class UART
{
public:
UART(const std::string& UARTPath): m_Open(false), m_PathToUART(UARTPath) {}
[Code]....
I'm probably going to handle all errors through exceptions. So if I can't open the UART bus, I'll throw an exception.
The I2C bus is a problem. I have a model which deals with it on a register-based level, but ideally I'd like to be able to model and use the devices on the I2C bus on a flag-based level (ie, I have names for each individual flag in the registers which I can read or write to directly instead of writing a hexadecimal value directly to each register).
Here is code:
Code:
namespace Buses {
template<unsigned int Id>
class I2CDevice {
public:
I2CDevice(I2C& Bus): m_Bus(Bus) {}
template<typename T>
[Code]....
So I2CDevice does some checks to see that the data to write to a register is either 8 or 16 bits. It does not check that the size to write matches the register's size, but another class does not.
The idea is also that it checks which device is currently active on the bus, and if it's not the current I2CDevice, then it simply selects that before attempting to read or write (the Open call).
This is not meant for multi-threaded environments. Yet, anyway.
The Impl2::Read/Write just dispatches the call so it calls the correct function for writing and reading the correct size, depending on the size of the data.
This is all well and good, but I2C works with registers, so of course I want a class to model a register which I can read and write to directly. It must tie into the bus class since the bus class is the one that abstracts reads and writes on the bus.
The register class looks like:
Code:
template<unsigned int Bits, unsigned int RegisterId, typename Bus_t>
class Register {
public:
typedef typename Impl::RegisterBase<Bits>::Storage_t Storage_t;
static_assert(!std::is_same<Bus_t, Buses::UART>::value, "Cannot read and write registers on the UART bus.");
static_assert(Bits == 8 || Bits == 16 || Bits == 32 || Bits == 64, "Number of bits must be 8, 16, 32 or 64.");
auto Write(Storage_t Data) -> void
[Code]....
I think this explains itself, except for the Regs struct, which is an experiment by me to enable myself to access registers via Regs.Config, etc.
What is missing is the ability to access and read/write the individual bits inside the registers. I am thinking a two-way access, where you can write to individual bits, but must call .Write() to commit the write to the register for efficiency.
I haven't actually written this. I don't know a good way ATM. I don't want to add a lot of variables and a write function because that would use 1 byte for every bit which is unacceptable.
I don't want to add a lot of code to make it work, either. A good get/set class would be nice, but I can't see that working. The register must store all state and any subsequent classes must not store any state or overhead will increase.
Finally, yes, I know a lot is incomplete and untested. It probably won't even compile. But that is for later. First is finishing the model.
It would be nice if things such as the platform and buses could be made static because there will only be one instance at any time, and that would save overhead if I don't have to store objects or references to them, but I haven't figured out how to achieve this.
I have made a complete solar system with key action for zoom in zoom out, moving along x, y, z axes on plus or minus and going up/down/right/left. I am now in a bit of a dilemma. I want to add a text window ( i have made my project in visual studio 2010 in win32 console application) where to put a text like a description of each planet to appear when i hit the left mouse button. E.g. When i click with the left mouse button the Venus planet I want a description to appear in my text window. However I don't know how to put make a text window and how to correctly define the picking methods... for now everywhere i hit the mouse button it appears in to the console that i hit the sun.
View 10 Replies View RelatedI am making a console based database system. Because I have to keep inserting, editing , deleting data blocks from my record file I have decided to use either vectors or list to store the all records. From the file I shall read the entire vector/list and work with it to add , remove or edit record and then again write the entire vector/list to the file again. I figured it would stop all the weird things that happen when directly working with the file. Is it an efficient way ?Or is it totally unnecessary ?Is there a better way?
View 2 Replies View Related