C++ :: Regular Expressions Not Working?
Aug 25, 2014
I have this bit of code that I found here: [URL] and at first regex would work, but then when I hit "[]" it wouldn't. Here's the code:
#include <iostream>
#include <string>
#include <regex>
[Code]....
View 2 Replies
ADVERTISEMENT
Sep 5, 2013
So I need to use boost/regex for regular expressions. someone told me that it needs to be built. the first problem is boost doesn't tell you how to build it and the second is i did sudo apt-get install libboost something. I don't remember the exact name of the package. it installed but i dont know how i would build it when its installed.
View 2 Replies
View Related
Dec 11, 2013
writing a program for "Validating the e-mail id without using regular expressions in c/c++"?
View 4 Replies
View Related
May 22, 2014
In order to parse mathematical expressions I am trying regular expressions and a recursive algorithm, but I have a problem with the four basic operations: +, -, *, /.
Trying to analyze a string like "a+(b+c)", if I use the pattern for a sum "(.+)+(.+)" the program matches it recognizing as subpatterns: "a+(b" and "c". How could I achieve the program to try also the other possibility?
I think that it would be great something like an regex_iterator which worked with regex_match instead of regex_search. I mean, an iterator that iterates over all the possible ways to match a given regular expression and a given string. This way I could loop through all these possibilities until the two subpatterns produced were correct mathematical expressions.
View 3 Replies
View Related
Oct 23, 2013
I am trying to create a NFA from a regular expression. I have a grasp on reading in the regular expression and being able to make a stack from it. The part I am struggling on is mapping the characters in the regular expression to an integer indicating the variables order in the expression. I am just not sure how to go about this.
My code so far...
Code:
#include<stdio.h>
#include<stdlib.h>
#include "stack.h"
int main(void)
{
char expression[80];//array to store regular expression
[Code] .....
View 6 Replies
View Related
Nov 27, 2014
Code:
int main() {
char *arr[] = {"Hello", "World", "Good", "Morning"};
display(arr);
return;
}
[code]....
The code works fine and prints the 4 strings. Where i m riddled is whether "ptr" in display function is a pointer or a string ? If it's a pointer then what is the type of the pointer? If it's an array, then as per my understanding, we cannot use an array name in expressions such as ptr++ (K&R).
View 2 Replies
View Related
Jun 26, 2013
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main () {
[Code] ....
I'm not sure why my loop isn't running right. I've also used if/if and if/else . Nothing worked
View 2 Replies
View Related
Aug 9, 2013
I really do not see the difference between these two declarations:
int myvariable;
int * mypointer;
It is said that when you define a pointer, instead of containing actual data, it contains a pointer to the memory location where information can be found.
But doesn't the other variable declaration do the same? It obviously doesn't have data either. And it must be stored in a memory location as well. So I do not see the difference.
View 6 Replies
View Related
Mar 31, 2015
I get the following error:
Cannot convert lambda expression to type system delegate because it's not a delegate type (on invoke).
The Second error is: Client.PrivateChat.txtReceive is inaccessible due to its protection level..
private PrivateChat pChat;
private void client_Received(Client sender, byte[] data) {
this.Invoke(() =>
{
for (int i = 0; i < clientList.Items.Count; i++) {
var client = clientList.Items[i].Tag as Client;
if (client == null || client.Ip != sender.Ip) continue;
[Code] .....
View 4 Replies
View Related
Aug 22, 2013
Its a code in module of my program, where I need to print current time (HH:MM:SS) at regular intervals.
Code:
#include<time.h>
#include<stdio.h>
//#include<windows.h>
void delay(unsigned int t){ // loop for some delay.
[Code] ....
But when I am running this code I expect this to print difference in time due to delay. But it doesn't enter the delay loop, why ?
View 5 Replies
View Related
Apr 9, 2012
<IMG border=0 alt="UserDeviceId = 70813215">
Above is the sample string object from this i need to find the integer value of UserDeviceId.
View 2 Replies
View Related
Jan 10, 2013
I am looking for a library to aid me in evaluating Boolean expressions. For example, i have an expression like this:
(1*(5+3)+9*65/5-(354*4565*5643+98) >= 12345) && ( 654*987+123 || (2345 > 23423 && 1 != 2)))
(It can also be much longer!) and would like to evaluate them to a true/false boolean.
There are tons of libraries to calculate the (numerical) result of a mathematical expression, but this is not what i want to do.
View 5 Replies
View Related
Jan 5, 2015
I have programmed a program for billing system. I have used parameters and arrays. All the functions are working except a one function. (Regular package function).
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
void main(int &minutes, int &minutesd,int &minutesn) {
[Code] .....
View 3 Replies
View Related
Sep 16, 2014
Can I use Shunting-yard algorithm to evaluate Expressions (arithmetic, relational, and logical) ?
View 8 Replies
View Related
Dec 3, 2014
Also, can't use namespace std for this.
#include<iostream>
#include<stack>
#include<fstream>
#include<iomanip>
#include<queue>
#include<cassert>
[Code] ....
/* It will read in a infix expression from a text file.check if the parentheses in the input expression are balanced.convert the infix expression into a postfix expression and evaluate the expression.*/
int main() {
string expression;
string postfixExpression;
double result;
testBalanced();
[Code] ....
View 8 Replies
View Related
Feb 22, 2015
1) ask the user to input a mathematical expression in the following format:
NUMBER Operator NUMBER Operator NUMBER
Example: 17 + 15 - 3
Example: 2 * 3 - 4
How to output the answer of the users equation. Is there a function that includes all math operators (+,-,/,*)? Would i need to write each possible scenario using if statements?
View 2 Replies
View Related
Dec 5, 2014
i have stuck in a join and i cant figure out where the problem is, i have those tables
public class Themes
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[Code].....
View 12 Replies
View Related
Apr 28, 2015
I have two questions that are related to each other. The first one is about overloading the addition operator.
I have defined a struct as the following:
Code:
#include <iostream>
#include <string>
struct Sales_data {
[Code] ....
I then overloaded the I/O operators so I could print to the screen information related Sales_data.
Code:
// overload ostream in order for cout to work
std::ostream& operator << (std::ostream & out,
const Sales_data & cSales_data) {
out << cSales_data.bookNo << ", " << cSales_data.units_sold << ", "
[Code] ....
My first issue is with overloading the addition operator. Everyone works correctly except for std::cout << item << std:endl; will no not output the ISBN number only the units_sold and revenue when added together.
Code:
// addition operator rules
Sales_data Sales_data::operator + (const Sales_data & data2) {
units_sold += data2.units_sold;
revenue += data2.revenue;
return *this;
}
Now here is the code in its entirety
Code:
#include <iostream>
#include <string>
// Sales_data structure
struct Sales_data {
std:: string bookNo;
unsigned units_sold = 0;
[code] .....
After total = total + item;, I would like to print the total for this particular ISBN. However, I only get: blank, total units, total revenue where blank is where the ISBN would go but doesn't print after addition. My second question has to do with comparing the ISBN's of the books entered during the while loop. I would like to do something like
Code:
if (item_i.bookNo == item_i+1.bookNo) {
total = total + item;
} else {
std::cerr << "Books entered must have the same ISBNs" << std::endl;
}
Unfortunately, I cannot figure out how to set up a comparison of the bookNos. If I used #include <casset> in the overload + rule, it will immediately exit since I have no way to compare the ISBNs.
View 3 Replies
View Related
Feb 25, 2013
I have the following code to calculate arithmetic expressions :
#include <iostream>
using namespace std;
using namespace std;
const char * expressionToParse = "6.5-2.5*10/5+2*5";
char peek(){
return *expressionToParse;
[code]....
The problem is that it does not work properly with decimal numbers for example it evaluates 6-2*10/5+2*5 = 12 which is correct but for 6.5-2.5*10/5+2*5 it returns 6 instead of 11.5 .
View 3 Replies
View Related
Mar 14, 2014
I have an EDI file whose structure is given below. This file has multiple records, each record contains a header (e.g EDI.DD.0000000001.20130809), then contents (i.e multiple paragraphs of text) and then footer (e.g End of Report/No EDI Activity). I have to read that entire file using regular expression using three groups.
I am using following regular expression to read the file.
(?<header>[A-Z]{3}.[A-Z]{2}.[0-9]{10}.[0-9]{8}) | (?<footer> (EndsofsReport|NosEDIsActivity)) |
(?<content>(?<=k<header>).*(?=k<footer>))
That expression reads the "header" and "footer" in respective groups properly but didn't pick the contents between header and footer in "contents" group.
I have changed the font of header and footer in below file to understand the format. I am using asp.net 3.5 framework.
//------------------Start of EDI File---------------------//
EDI.DD.0000000001.20130809
ORIGINATOR INFORMATION Company Name: UNITED HEALTHCAR Identification: 9024125001 Originating DFI: 002100002
RECEIVER INFORMATION Receiver Name: HEALTH & WELLNESS DFI Account Number: 0000000000000001 Receiving DFI ID: 434343430 ID Number: Transaction Type: 22 Deposit
ORIGINATOR INFORMATION Company Nam
[Code] ....
View 1 Replies
View Related
Jan 17, 2015
lets say we have a valid class with full implementation, X. can this class be declared as forward in Y header file:
Code: class X;
class Y{
X* m_X;
}
but still be used as regular in the cpp file?
Code:
#include "Y.h"
#incldue "X.h"
T Y::function(){
m_X->doSomething();
}
visual studio prevents me from doing it , I wonder if the standard also says so.
View 2 Replies
View Related
Mar 6, 2015
Whenever I put my dll files in the same directory as my main.cpp and use this code, Code: g++ main.cpp -L. -lMyDll it works.
but if my dll files are in the other directory, Code: g++ main.cpp -L/myDlls -lMyDll it won't work. Why is this not working?
View 6 Replies
View Related
Jul 5, 2014
i am currently trying to get SDL working with C language.I am using Cygwin and Sublime text 2.I know and understand general programming, however i am trying to understand how to get SDL working with a file i create i.e test.c. i know to include which i have downloaded
#include <SDL.h>
where do i add the libraries so that i can use them in my program?
View 9 Replies
View Related
Apr 16, 2014
I am writing an irc bot in c++ on linux mint, and its not connecting right for some reason. anyways, heres the link: [URL].... . it was connecting to quakenet before I added the functions, but now it just says connecting... and then quits.
View 12 Replies
View Related
Apr 3, 2013
I'm learning network programming and I've decided to program a simple c++ irc bot. I'm able to connect to server and send commands. But when I try to receive and show message from server I first get a few lines, like "Please, wait, while we process your connection" or "Found your hostname". And then I start to get a ton of information about the server. Here is the whole class:
header file:
#pragma once
#include <WinSock2.h>
#include <WS2tcpip.h>
class bot {
public:
bot(char *_server, char *_port);
~bot(void);
[Code] .....
Link to whole visual studio project: [URL] .... Am I doing something wrong during the IRC connection? Or I didn't understand how networking work?
View 19 Replies
View Related
Jul 25, 2014
When inserting elements in a set it should only insert unique elements but I get duplicates too.
Code: #include <iostream> // cout
#include <algorithm> // unique, distance
#include <string>
#include <iterator> // std::back_inserter
[Code].....
View 3 Replies
View Related