![]() |
| | #1 |
| Registered User Join Date: Nov 2009
Posts: 13
| Regex Pattern Question Code: char name[BUF_SIZE];
sprintf(name,argv[2]); /*copy netid into name */
printf("Grade Info For '%s'\n\n",name);
sprintf(name_grade, "(\\-.[char name goes here]).\\|.([0-9]+)");
The file input format is Code: - studentname | 29 |
| surefire is offline | |
| | #2 |
| Registered User Join Date: Oct 2006 Location: Canada
Posts: 1,230
| So if the given argument has name "bob", the regex should look like "- bob | ([0-9])+"? Why dont you just print it? Code: sprintf(name_grade, "(\\-.%s).\\|.([0-9]+)", name); |
| nadroj is offline | |
| | #3 |
| Registered User Join Date: Nov 2009
Posts: 13
| Awesome, didn't realize that was an option. Thanks! |
| surefire is offline | |
| | #4 |
| Registered User Join Date: Oct 2006 Location: Canada
Posts: 1,230
| No problem. Keep in mind that "sprintf" and "fprintf" are the string- and file-output equivalents of screen-output "printf", respectively. So anything you can do in "printf", is just as easily done in the other functions. |
| nadroj is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| a sed and regex question | lehe | Linux Programming | 1 | 09-03-2009 01:05 PM |
| Visitor / Decorator Pattern | MarkZWEERS | C++ Programming | 9 | 05-16-2009 11:53 AM |
| Hmm.. Ai? Finding the pattern in number squences? | Zeusbwr | C++ Programming | 8 | 04-02-2005 06:13 PM |
| Question... | TechWins | A Brief History of Cprogramming.com | 16 | 07-28-2003 09:47 PM |
| (pattern *) pat & pattern * pat | siubo | C Programming | 1 | 04-08-2003 10:03 PM |