and get an Iterator to the beginning of the match by
matches->at(i)->begin()
How can I get the relative position of the match within the entire target string (i.e. "Unseen University", where, in this case, the positions should be 0 and 7)??
// Creating and joining string objects #include <iostream> #include <string> using std::cin; using std::cout; using std::endl; using std::string; using std::getline; // List names and ages void listnames(string names[], string ages[], size_t count) {
[Code] ....
I may be wrong, but the problem seems to be in the function "listnames". Specifically, the output statement inside the while loop. I don't understand , how the ++ operator is behaving in this statement. The output produced does not match what's printed in the book. I usually just type all the examples, but with this one I also downloaded the source code from the book's website to make sure the error wasn't due to mistyping.
Using the old fashioned (unsigned) multiplication instruction in x64 assembly multiplies RAX (64 bit register) by a 64 bit register. The answer is stored in RDX:RAX (i.e. the answer is 128 bits). Is there any way, using native c++ to get the value in RDX (higher 64 bits)? One I can think of is: right/(limit/left) e.g. if we are limited to a byte then 97*123 would overflow:
97/(255/123) = 46 times, which is RDX's (if it was one byte) value. But this is too inefficient. Is there a fast way?
I haven't found anything that small for Matrix multiplication i was just going to ask about how i would multiply to matrices together in c++ as easy as possible, so for example say a i have the following
[2 0 1 0 * [3 0 6 -1 0 2] 0 3 1 2 3 1]
How would i multiply these together. Here is the example
I'm doing a refresher for C++ and have gotten to operator overloading. I'm trying to perform an operator overload with the insertion (<<) operator, but I have encountered a problem.
Here's my class [In a header file "Shinigami.h"]
#include<string> namespace K{ class Quincy; class Shinigami{ friend std::ostream& operator<<(std::ostream&, const Shinigami&);
[Code] .....
If the operator function is a friend of the 'Shinigami' class, why doesn't it recognize any of it's private members? I need it to be in this file because I'm doing a bit of association with the 'Quincy' class.
I thought it was the namespace, but I included that.
I am new to C programming and I am just wondering how to multiply / divide two different variables which the user type in as the promt is asking like this:
Code: void inmatning3 (double *a, double *b) { printf("Mata in tv217 stycken flyttal: "); /* asks you to type in 2 numbers */ scanf("%lf %lf", a, b); }
When you've enterd the two numbers I need to eather multiply or divide the two variables "a" & "b" .....
I've been working on this program to create a simple desk calculator for a school assignment, and I managed to finish. All we had to do was add, subtract, multiply, and divide positive integers - and I was able to do that just fine. This program got me thinking though, because I do not know how to write commands to multiply/divide negative numbers.
In fact, when I divide a number like 21 by 4, it comes out to 5 because I don't know how to allow it to compute remainders (which wasn't a requirement for my program). This intrigued me so I've been trying to figure it out for the last few days but to no avail. Here's my code:
Code: void flush_buffer(){ int ch; while ((ch = getchar()) != ' ' && ch != EOF);
[Code]....
And just know that my code works perfectly fine, I'm not here for troubleshooting it. I just want to know what I can change to allow negative values to be correctly computed.
#include <iostream> using namespace std; int main(){ int polje[8][8];{ for(int i=0;i<8;i++) for(int j=0;j<8;j++) {
[Code] .....
I don't get any errors,the program works. The problem is that it doesnt work how it should. This is a simple program that multiplies 2 variables(i and j)that go from 0 to 7. The problem I have is with the logical operators,i want the program to skip multiplication with 0 and when the 2 variables are the same value. When i try using only 1 logical operator it work.
I know how to find find ASCII value of given character, but I am not getting how to find ASCII value of given string. For example I want to find ASCII value of string "HELLO",so how to do that.
So the program reads contents from a text file into a vector and then the user enters in a string that they want to search for. The program iterates through the vector to find the string and then saves that line to another vector to display later(incase there is more then 1 instance of the string found).
Here is what I have atm:
void doSearch(vector<string> &phonelist, string searcher, vector<string> &holdNumbers) { int i = 0; string value;
[Code].....
I just get an R6010 error -abort() has been called.
printf(" Enter a line of Morse Code for decrypting"); scanf("%s",phr); len=strlen(phr); for(a=0;a<36;a++) { if(strcmp(phr, morse[a])==0) printf("%c", alpha[a]); };printf(" ");
The output :
[output] Enter line to encrypt: ..... -.... --...
converting... 5 [/output]
It should read all code, including null. between coded letter one space, between coded word three spaces.
I am stuck in some logic and want to write a program to do following tasks : I have three string variables to be compared to each other,a string having sub string & hierarchy string!!
1.) name1=john name2=tom_john_tom name3=alextom_john thus we need to search john from name2 and name3 and if name1 exists in both name2 and name3 then ok else check for step2
2.) name1=a.b.c.d ,name2=a.b.c.d and name3=a.b.c.d we need to compare each string seperated by a dot in all three variables and we need to match each string seperated by a delimeter "." if name1.a==name2.a==name3.a and name1.b==name2.b==name3.b ,name1.c==name2.c==name3.c and name1.d==name2.d==name3.d then its a match else its a mismatch
Also,the catch is we can have name1 ,name2 and name3 in format name1=*.*.*.* and name2=*.*.*.* and name3=*.*.*.* where * defines it can be any value to be matched
I'm building two DLLs - let's call them DLL_A and DLL_B. DLL_A builds as a standalone entity but DLL_B needs to link to the lib file for DLL_A (i.e. it imports some functionality from DLL_A). While linking DLL_B I see lots of errors taking the following form (bear in mind that port.cpp and port.h are source files in DLL_B:-
I'm not sure if I'm reading that correctly but to me, it seems to be saying that some STL components are somehow getting exported from DLL_A (std::vector maybe?? Or std::string??) and that they conflict with similar objects already in port.obj. Sure enough, when I used dumpbin /EXPORTS on DLL_A there did seem to be some evidence that that was true. So my next step was to examine the source code for port.obj. Of course, strictly speaking I should be examining some code from DLL_A but it has hundreds of source modules so I figured that I should start by identifying whatever it is in DLL_B that's throwing up the conflict (since I at least know which module the conflict is in!).
When I examined the source files for port.obj, std::string seems to get used quite often - but fortunately I could only find one occurrence of std::vector.
In port.h it occurs here:-
Code: class DLL_B_API Port : public boost::noncopyable { public: // c'tors + d'tors int get_connections (std::vector<std::string> &) const; // rest of class
In port.cpp it occurs here:-
Code: int Port::get_connections (std::vector<std::string> & c) const { if (!port_engine.available()) { c.insert (c.end(), _connections.begin(), _connections.end()); return c.size(); } return port_engine.get_connections (_port_handle, c); }
Is there anything in there that would be causing the above linker error? It's entirely possible that I'm looking in the wrong place but I suppose I've got to start somewhere....
I just found a possible clue in one of the header files for DLL_A, where I found this class declaration:-
Code: namespace PBD { class DLL_A_API Searchpath : public std::vector<std::string> { // Whatever... }; }
Might that be causing std::vector<std::string> to get exported?
I got a homework that require to count number of words in a text file and also display the first and last 10 words of the text file to the console. I have finished the counter problem and now I struggle showing the first and last 10 words.
#include <iostream> #include <sstream> #include <string> #include <fstream> using namespace std; int tokenize(string sentence, string tokenizedWords[]);