C/C++ :: Cannot Find Out Why A Certain Part Is Looping

Jan 20, 2015

I am having a little bit of trouble with what should be a simple part in my code. For some reason it keeps looping the name part of the program and I seem to be passing over the problem in the code.

Here is the code:

#include <iostream>
#include <string>
using namespace std;

[Code]....

View 6 Replies


ADVERTISEMENT

C++ :: Find Biggest Part Of Column Over Diagonal Of Matrix

Jan 23, 2013

How to find the biggest column of the matrix (higher of main diagonal) Here is the draft of code that i desighned/ Of cause it has a several mistake. My task is here to create the matrix, allocate the dynamic memory for it, and to find the biggest sum of the column elements that is located over main diagonal. So main points is correct memory allocation, and the sorting to the biggest sum of column higher than diagonal.

#include<iostream>
#include<conio.h>
#include<time.h>
using namespace std;

[Code]....

View 5 Replies View Related

C++ :: How To Tell Function Which Part Of Struct To Use

Jul 4, 2013

Say I have a structure defined as such:

struct data{
char c;
int x;
};

And I want to create a function to print either c or x. However, I don't want to just use a switch or something to figure this out, I want to reference which part I'm outputting.

Now here's the twist

vector<data> dataList;

I need to access element x or c in the vector, but all I pass is the vector and which element, so that I might have something like:

void (vector<data> x, DataType i){
cout << x[0].i;
}

So now, if I pass either x or c (someway), I can output one of them.

View 19 Replies View Related

C++ :: How To Delay Part Of Code

Jul 1, 2014

for example i have

int count = t1;
while(count>counter){
Sleep(delay);
Int32::TryParse(textBox2->Text,add);
result = result + add;
counter = counter + 1;

Problem is that sleep stops all program for specified time, Is there an alternative to sleep that would only stop part of code or can i use sleep different way to specify what it pauses?

View 8 Replies View Related

C++ :: Clear Part Of The Screen?

Nov 3, 2014

Is there any way I can clear only a selected part of the screen? (I'm aware of system("cls"))

For example, when you enter a date, and is wrong, could it just errase that input and only say "Wrong try again" without errasing everything else you where doing?

In this case, a function that only errases what is in the while

while(not wrong)
{
cout<<"DIA: ";
cin>>obj.dia;
cout<<"MES: ";
cin>>obj.mes;
cout<<"ANIO: ";
cin>>obj.anio;
}

PS: Also, is there any whay in which you can ask the user to enter the date DD/MM/YYY?

View 1 Replies View Related

C++ :: Object To Return Part Of Itself

Dec 7, 2013

Is it valid for an object to return an object of they same type? GetBlock method

class memBlock {
private:
char *mem;
unsigned long length;
public:
memBlock(char *data,unsigned long startPoint, unsigned long endPoint) {

[Code] .....

View 1 Replies View Related

C/C++ :: How To Delete Part Of The String

Nov 26, 2012

I have the following string: "type computer {dell}"

And I want to remove the {dell}

So that the output on the screen type computer

Or delete any clause between the two brackets {}

How do i do that ?

View 5 Replies View Related

C++ :: Erase Part Of The String?

Sep 29, 2014

Code:
// string::erase
#include <iostream>
#include <string>
int main () {
std::string str ("This is an example sentence.");
std::cout << str << '
';
str.erase (10,8);
std::cout << str << '
';

Code:

Output:

I don't understand this program. What do these 2 numbers represent? The index of an element in a character array? The 10th character of the array is 'n' and 8th is a "space".

View 14 Replies View Related

C++ :: Looping With Different Values?

Dec 9, 2013

I want to write a loop to check for prime numbers. So I'm going to check only numbers ending with 1,3,7,9.

So I need a loop that will increment with 2,4,2,2 and again 2,4,2,2...

What king of loop is best, a 'for loop' or a 'while' with switches in it or something else?

Basically I need to increment three times with 2 and then with 4, three times with 2 and then with 4...

View 9 Replies View Related

C/C++ :: Infinite Looping For Map?

Jan 13, 2015

I have been trying to get this piece of code to work but it seems to be running infinitely. What i'm trying to do is that whenever the iterator points to the map element, I check whether the element is 1 or 0. If it is 0, *do something*. But if it isn't, it should not do anything and proceed to the next element in the map.

//infinite loop - not working!
for (MapType::iterator p = pwCounter.begin(); p != pwCounter.end(); ++p) {
if (p->second.second != 1) {

[Code]....

View 1 Replies View Related

C :: How To Convert Part Of String And Integer

Jan 2, 2014

I'm having a problem converting part of a string to an integer.I used strtok to seperate my string and I have also a function for atoi but how to apply it to my strtok function.What i need is to change the char *years to an int.Have a look of what I got:

Code:
int main() {
char sentence[]="trade_#_2009_#_invest_#_DEALING";
char *word=strtok(sentence, "_#_");
char *year=strtok(NULL, "_#_");; // assigning NULL for previousely where it left off
char *definition=strtok(NULL,"_#_");
char *synonyms=strtok(NULL,"_#_");

[code]...

View 2 Replies View Related

C :: Strcat With Nulls As Part Of Array

Mar 30, 2014

I have a character array that includes configuration bits that are 0x00, thus when I try and do a strcat it adds the appended string into one of those spots instead of the end of the array.

View 2 Replies View Related

C++ :: Algorithm To Get The Decimal Part Of A Number?

Jun 12, 2014

I'm writting an algorithm which equals to std::to_string. The inttostring part is fine, and the decimal_part too. But when the number digits > 5, the program loops infinitely.

#include <iostream>
#include <string>
#include <algorithm>

[Code]...

In this code, the program runs ok. But try to add a 5 at decimal_part. What should I do to get this 'decimal_part' ok?

View 6 Replies View Related

C++ :: Removing Part From A Vector Of Sets?

Apr 18, 2014

I have a vector of sets, which I am removing any element which contains a certain value. For example, if I was looking for 2:

[0] 1 2 3
[1] 4 5 6

After the program was run, I would be left with just [0]4 5 6.

This is the code I have been using

auto iter = std::remove_if( clauseVector.begin(), clauseVector.end(),[propagator] ( const std::set<int>& i ){
return i.find(propagator) != i.end() ; } ) ;
clauseVector.erase( iter, clauseVector.end() ) ;

I want to know, is there any way I can tweak this code so that it only removes one part of the set rather than the whole thing. For example with above example, I would be left with

[0] 1 3
[1] 4 5 6

View 4 Replies View Related

C/C++ :: Interest Calculator Math Part

Feb 11, 2014

math part.

The equation I need to use is: payment = [(rate * (1 + rate)^number payments ) / ((1 + rate)^number of payments -1)] * loan

Also, the value of rate in the above equation is (interest/12)/100. So 12% annual interest would be 1% monthly interest.

heres my code:

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

[Code].....

View 4 Replies View Related

C/C++ :: Undefined Reference On Declaration Part

Jan 29, 2015

I can't run my program. I have undefined reference on the declaration part , where is the error here :

#include <iostream>
using namespace std;
#define T_TABLEAU 5 //change la taille tableau ici
void TableauEntre(int* tab,int n);
void QuickSort(int* tab,int IndexPrem,int IndexFin);
int Partition(int* tab,int pivot,int IndexPrem,int IndexFin);

[Code] ....

View 11 Replies View Related

Visual C++ :: Function That Can Take Out Part Of The String?

Jul 10, 2013

Is there a function that can take out part of the string such as,

C:/Users

I want to take out Users.

I need the function to search for the first "/" and take out the last dir name

C:/windows would be c:
C:/users/bla would be c/users

Im programming in visual studio 6.0 MFC

View 4 Replies View Related

C++ :: Why Decrement Part Of The Code Not Working

May 17, 2012

Code:

#include <cstdlib>
#include <iostream>
#include <string>
#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include <exception>
#include <process.h>
using namespace std;
int main(int argc, char *argv[])

[code]....

View 10 Replies View Related

C++ :: Program Keeps Looping Infinitely

May 21, 2014

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

View 1 Replies View Related

C++ :: Looping Through Template Objects In Map

Dec 30, 2014

How to get this code working

template <typename T>
class Dummy {
// Implementation
};
template <typename T>
class SomeClass

[Code] ......

View 4 Replies View Related

C++ :: Looping And Calculate The Percentage?

Mar 7, 2013

#include <iostream>
#include <iomanip>
#include <math.h>

[Code].....

I AM HAVING TROUBLE CALCULATING THE PERCENTAGE. I HAVE TO CALCULATE THE AMOUNT OF MONEY FOR 6 YEARS.

View 1 Replies View Related

C++ :: Looping In CPP Class File

Jan 4, 2014

I have a class with a .h and a .cpp file. (I'm unique!) In the .cpp file, I have a loop and a nested loop. It worked fine when it wasn't in a separate file. Now, the loops will not loop and the value found at the end is some random out of the all park number because no looping took place. I am positive that the conditions and variables are set properly.

View 1 Replies View Related

C# :: Looping Through A Range Of IP Addresses

Feb 6, 2014

I want to take a starting IP on a local network, and loop through to an ending IP on a local network, pinging all the IP addresses in between. For instance, ping all IP addresses between 192.168.1.1 - 192.168.1.255 (user enters desired starting IP and ending IP in text boxes).

I have the ping functionality working, and i can make it all work with lots of messy string parsing.. but it seems sloppy to me.

I have to split the strings (start and end IP) to get the last octet, then subtract to get the range of IPs. Then loop through, adding 1 to the last octet, and converting back to a string each time.

The C# Ping class can use either a string or an IPaddress for its Send method. If I use IPAddress, I just have to convert it from the text box it originates in, but the adding 1 to the last octet in the loop is a hassle.

Anyway, I guess the only question I have is, if you had to loop through a range of IP addresses, how would YOU do it?

public Job(string ipStartIn, string ipEndIn) {
long ip1 = Convert.ToInt64(ipStartIn);
long ip2 = Convert.ToInt64(ipEndIn);
IPStart = new IPAddress(ip1);
IPEnd = new IPAddress (ip2);
this.deviceAlive = false;

[Code] ....

View 14 Replies View Related

C/C++ :: Looping Recursive Functions?

Feb 10, 2014

how to recursively modify my program. The problem I'm hacing is the the program is not looping correctly and also not printing the correct number. I've calculated the payoff correctly, also I've only been able to print the first section of R3. I can't figure out how to loop it to get R2 to stay at 2 then go to 3 after all possiblities of R2 at 2. Enventually, R1 will change to 2 then 3; 3 being the highest number earned. To be mentioned that will be three recursive function loopR1, loopR2, and loopR3 for each column.

The result of the program should look like:

R1 R2 R3
1 1 1 payoff is 1
1 1 2 .......... 1
1 1 3 .......... 1
1 2 1 .......... 1
1 2 2 .......... 1
...
...
...
3 3 2 .............. 5
this is what I have so far:

#include <stdio.h>
#include <stdlib.h>
int payOff(int r1, int r2, int r3);
void loopR3(int R3, int upto);
void loopR2(int R2, int upto);

[Code].....

View 12 Replies View Related

C/C++ :: Won't Stop Looping If Statement

Jan 22, 2015

My program is designed to take a reading from a glucometer and light an LED if the reading is too high or too low. I used this code:

#include <eHealth.h>
void setup(){
pinMode(13, OUTPUT); //first alert
pinMode(12, OUTPUT); //green LED

[Code]....

The glucometer stores the tests and the code just pulls the most recent one, however even if I unplug the glucometer the first if statement keeps repeating and the LED in pin 12 keeps shining. Is it the if statement itself malfunctioning, or is the Arduino storing the data it pulled and just repeatedly plugging that into the if loop?

View 3 Replies View Related

C++ :: Define A Class Arc Which Draws A Part Of Ellipse

Apr 24, 2014

The exercise is : Define a class Arc, which draws a part of an ellipse.

Hint: fl_arc()

And the body of the class ellipse is as follows in the book (PPP):

struct Ellipse :Shape {
Ellipse(Point p, int w, int h); //center, max and min distance from center
void draw_lines()const;
Point center()const;
Point focus1()const;
Point focus2()const;

[Code] ....

And the fl_arc() probably is part of FLTK which I've installed it on my machine.

Now the problem here is that while I don't can see the full version of the body of the ellipse how to do this exercise?

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved