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
ADVERTISEMENT
May 2, 2013
I'm trying to use the find string to erase a ' ' from the end of a word. I tried something along the lines of:
if (SecondSide.find('
')!= string::npos)
SecondSide.erase(SecondSide.find('
'));
but it had no effect.
View 7 Replies
View Related
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
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
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
Dec 9, 2013
I have a string that contains a various number of lines which are each separated by and so what I want to do is to put each line into a node in a linked list.The relevant sections in my code are as follows:
Code:
typedef struct line *Line;
struct line {
char *text;
int lineNum;
Line next;
}
[code]....
Code:
strncpy(curr->text, text[prevPos], subLength);
With this line, I was hoping to make curr->text a string that is length subLength and begins at position prevPos in the text string. Except text[prevPos] is treated as a single character and not a string that begins at that position.
View 8 Replies
View Related
Feb 4, 2013
Well, I have a .txt file that contains, together with a few characters, columns of values that I want to save in different files like is written in the program (file 1, file2, file3 - a with x, b with y, c with z). BUT, I don't want the values from the lines with the saying "interpolated_vector" to be printed in any of the three files.
What I have is the code below, that has the code that creates the three new files with the columns of values that I want. It is working fine!
Code:
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
int i, count;
double *a, *b, *c;
double *x, *y, *z;
char tag[5][255];
[Code]...
I've tried and tried, but couldn't make it work properly. I could only erase one line with "interpolated_vector" using fgets, but all the other lines below this were printed into the three new files (file1, file2, file3).
View 5 Replies
View Related
Apr 4, 2014
vector<int> *vec; allocate memory and
suppose vec conatins 10 values then
erase(vec->begin(),vec->end());
vec.clear();
both should be used or any one one is fine to erase all ??
View 1 Replies
View Related
Mar 17, 2014
I wud like to delete multiple values from a vector using indexes as my values r not fixed they may change so using indexes i want to delete
For example: vector<int> v={1,2,3,4,5};
I want to erase 3,4,0 indexes
So resulting vector is 2,3
View 6 Replies
View Related
Oct 7, 2014
So in my winform form, I have a table layout panel and I attach Controls on the row. I make some control span multiple columns... But since I use transparent for the background of the layout panel, it show the border between 2 cells that I span.. Like this:
How do I erase the border in the middle of IDLabel?
View 14 Replies
View Related
Sep 5, 2013
I am doing a project which I have to read, write and erase data from a NorFlash Memory. Then, I have to compare those data files in order to find errors.
Besides, I would like to know which is the best way to TEST errors in this kind of memories.
I am using NetBeans 7.3.1 for writting the code and Cygwin running on Windows XP Virtual Machine. The Memory Flash (S29JL064J 64 Megabit) is incorporated on an external board which is connected to an adapter board (using HDMI cable). This adapter is connected to the Laptop (using an USB).
View 3 Replies
View Related
Nov 26, 2014
// my size is not decreasing when I erase a record.
//dvr_hwch.cpp
#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;
#include "hash_chn.h"
void print_menu( );
[Code] .....
View 1 Replies
View Related
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
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
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
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
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
View Related
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
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
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
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
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
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
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
Jul 31, 2013
How can I Passe some part of multi-Dimensional Array to a Function; for example only two dimension of three dimension of a an array with 3 dimension. This is because my function is defined for working with 2 dimension arrays.
View 3 Replies
View Related
Feb 25, 2013
I want to compare the part of the character array with the scanned input. I've initialized the character array (colourCompare).
What I want to do is, if the input colour matches up with one of the elements in the colourCompare array, it will then read the next value(I did not include "read the next value part"). If the input does not match up, then it goes back to the scanning part.
Code:
char colourCompare [12][6] = {"Black","Brown","Red","Orange","Yellow","Green","Blue","Violet","Gray","White","Gold","Silver"};
float resistanceCal() {
[Code]....
View 14 Replies
View Related