Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 447 results for
delimeter
- Page 1
Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by PinoyDev
Good day! I knew this is easy to all of you guys. But I need the most precise way to parse this string "**45:50"** and store the result in **two dimensional array with int as datatype**. The
delimeter
is "**:**". Thank you!
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by nmaillet
Take a look at [strtol](http://www.cplusplus.com/reference/clibrary/cstdlib/strtol/) for signed long integers or [strtoul](http://www.cplusplus.com/reference/clibrary/cstdlib/strtoul/) for unsigned long integers. In particular, look at the example from the first link; it could easily be made into a loop that can handle your problem.
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by WaltP
Look at each character and convert to decimal. Easy peasy. `strtoul()` will take time and testing to understand, you can convert this by hand in 10 minutes.
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by myk45
@OP: How about using [sscanf()](http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/)? you can trying something like `sscanf(buffer, "%d:%d", &a, &b); // where buffer is your string` So, you can check the return value of sscanf(). If it returns 2, then it means your string had the necessary pattern. So, you can …
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by iamthwee
Or you could use sstream... Again it all depends on your preference. C++ is a multi-paradigmed language after all, if you choose to use c style solutions you can.
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by PinoyDev
Jusy a try but Im having a closed loop. If I enter "45:50", it displays 45 only continously. My code so far: #include<iostream> #include<cstdio> using namespace std; int main() { char input[5]; char * output; cout<<"Enter a string: "; cin.getline(input,5); …
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by deceptikon
strtok() is funky in that it works using an internal state through multiple calls. To get the next token you need to call strtok() again with a null first argument (so that it knows to use the previously passed string): output=strtok(input,":"); while(output != NULL) { cout<<output<<endl; output=…
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by PinoyDev
Thank you deceptikon! Ive modify the code. But when I enter "45:45" I get 45,4. The last character is missing. And also, fflush(stdin); cin.get() is not working. #include<iostream> #include<cstdio> using namespace std; int main() { char input[5]; char * output; …
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by WaltP
>fflush(stdin); //this does not work why? It's not designed to work. [See this](http://www.gidnetwork.com/b-57.html). >cin.get(); //this does not work why? That's because of `cin.getline(input,5,'\0');`. You left stuff in the input buffer. Just use `cin.getline(input);` >But when I enter "45:45" I get 45,4. The last …
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by deceptikon
> But when I enter "45:45" I get 45,4. The last character is missing. Read *all* of my reply next time, I predicted this problem and explained and how to fix it. Bump up the size of your array by 1, and account for that new size in your call to getline(). Adding '\0' as the third argument to getline() is silly and pointless because …
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by PinoyDev
Thank you WaltP, deceptikon! Ive added the two dimensional array. #include <iostream> using namespace std; int main() { char line[1024]; // Abritrary "big" size int i, Num1Num2[1][1]={0}; cout << "Enter a string: "; if (cin.getline(line, sizeof line)) {…
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by WaltP
> int Num1Num2[1][1]={0}; What the heck is this? You set up a 2-dimensional single integer. Why? It's completely worthless.
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by PinoyDev
Thank you WaltP! Well, that two dimensional array is a preparation. Just because I want to extend the program to hold an output of 2 array in size with 5 elements. I would extend something like Num1Num2[2][5] later..
Re: Parse a string with delimeter??
Programming
Software Development
11 Years Ago
by WaltP
OK. That makes more sense. I thought you were having an aneurysm ;o)
Error message from Dev C++ saying "Called object is not a function"
Programming
Software Development
14 Years Ago
by mattitude
…if(format==1){ if (line_search(
delimeter
, paragraph_list[paragraph_number][line_number], wild)!=-1){… newslide = 1; } a = line_search(
delimeter
, paragraph_list[paragraph_number][line_number], wild); } } fscanf…
Re: Memory Problem After a certain limit
Programming
Software Development
14 Years Ago
by Dream2code
… ===COLUMN 1=== HEADER:"name" DATATYPE:"0"
DELIMETER
:"|" ===COLUMN 2=== HEADER:"age" DATATYPE:"…===COLUMN 12=== HEADER:"sex" DATATYPE:"0"
DELIMETER
:"\n" ========================= TESTING BREAK1 Segmentation Fault (core dumped) sdetlab01…
Re: Memory Problem After a certain limit
Programming
Software Development
14 Years Ago
by Dream2code
… ========================= ===COLUMN 1=== HEADER:"name" DATATYPE:"0"
DELIMETER
:"|" ===COLUMN 2=== HEADER:"age" DATATYPE:"… ===COLUMN 10=== HEADER:"sex" DATATYPE:"0"
DELIMETER
:"\n" ========================= TESTING BREAK1 Record 1: ========= name:"…
Re: Error message from Dev C++ saying "Called object is not a function"
Programming
Software Development
14 Years Ago
by gerard4143
char slide[20] and int slide(FILE *ifp, char
delimeter
[], char wild); are both defined to mean two different things...I'm guessing that slide[20] is hiding the function slide.
Re: Error message from Dev C++ saying "Called object is not a function"
Programming
Software Development
14 Years Ago
by mattitude
[QUOTE=gerard4143;1121307]char slide[20] and int slide(FILE *ifp, char
delimeter
[], char wild); are both defined to mean two different things...I'm guessing that slide[20] is hiding the function slide.[/QUOTE] Thanks, I knew it was something easy like that:)
Returns null pointer
Programming
Software Development
15 Years Ago
by savinki
…} void Split(string Message) { unsigned int counter = 1; char
Delimeter
= ','; char * ArrayMessage; string tempValue; stringstream InputData; ArrayMessage = new… strcpy (ArrayMessage, Message.c_str()); m_szCommandName = GetSection(&ArrayMessage,
Delimeter
); printf ("%s\n",m_szCommandName); //delete []ArrayMessage; …
TinyButStrong Templating System, the basics and simple tweaks
Programming
Web Development
11 Years Ago
by veedeoo
… the template engine that I want my
delimeter
change to {{ and }}. Why change the default
delimeter
? Well, the response is simple.. I… smarty templating environment.. In fact we can change the
delimeter
to Twig like
delimeter
e.g {% and %} .. but that is not within…
String splitter
Programming
Software Development
17 Years Ago
by mmiikkee12
… strsplit(const char *str, char splitchar, int token_num) { char *
delimeter
= "\0";
delimeter
[0] = splitchar; int i; strcpy(str, line); char… on the line */ { /* search for delimiters */ size_t len = strcspn(token,
delimeter
); token[len] = '\0'; /* print the found text: use *.* in format…
Re: String splitter
Programming
Software Development
17 Years Ago
by Ancient Dragon
…(const char *str, char splitchar, int token_num) { char *
delimeter
= "\0";
delimeter
[0] = splitchar; [color=red]^^^ delimiter is a ponter that… on the line */ { /* search for delimiters */ size_t len = strcspn(token,
delimeter
); token[len] = '\0'; [color=red]^^^ this is identical to strtok…
Re: String splitter
Programming
Software Development
17 Years Ago
by mmiikkee12
…)] = '\0'; } printf("%s\n", tmpbuf); char *
delimeter
= "\0";
delimeter
[0] = splitchar; char *token = tmpbuf; /* point to the beginning… on the line */ { /* search for delimiters */ size_t len = strcspn(token,
delimeter
); token[len] = '\0'; /* print the found text: use *.* in format…
Interest??? Here
Programming
Software Development
17 Years Ago
by rapperhuj
…(whole,800,f)!=0) { int a=0, i; char
delimeter
[]="-\"", who[100][100]; char *huj=strtok(whole…a++>=sizeof who/ sizeof *who) { break; } huj=strtok(NULL,
delimeter
); } for (i=0; i<a; i++) { strncpy(who[i…
EXCITING PROBLEM... Please Help and give me a SOLUTION 2 this Problem
Programming
Software Development
17 Years Ago
by rapperhuj
…0) { int a=0, i; char
delimeter
[]="-\"", who[100][100]; char …*huj=strtok(whole,
delimeter
); while(huj!=NULL) { strcpy(who[a…/ sizeof *who) { break; } huj=strtok(NULL,
delimeter
); } for (i=0; i<a; i++) …
Memory Problem After a certain limit
Programming
Software Development
14 Years Ago
by Dream2code
…, DP Description file format: ======================== begin columname datatype("
delimeter
"); columname datatype("
delimeter
"); . . . . end; EXAMPLE: -------- begin name string("|&…;name","age","sex"); char *
delimeter
[]={"|","|","\n"}; 2)When we…
Re: String splitter
Programming
Software Development
17 Years Ago
by mmiikkee12
… it works perfectly if there's a trailing / (or whatever
delimeter
) on the end of the string. But not every filename…
Re: EXCITING PROBLEM... Please Help and give me a SOLUTION 2 this Problem
Programming
Software Development
17 Years Ago
by thekashyap
>> huj=strtok(NULL,
delimeter
); [COLOR=Black]This will core, see man strtok.[/COLOR]
convert stringstream to a string
Programming
Software Development
15 Years Ago
by savinki
…code] void countParameters(stringstream p_InputDataToCount, unsigned int &counter, char
Delimeter
) { size_t found; //stringstream convert ( p_InputDataToCount ); //convert>&… this found=[COLOR="Red"]p_InputDataToCount[/COLOR].find_first_of(
Delimeter
); while (found!=string::npos) { counter++; found=[…
1
2
3
8
Next
Last
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC