I've been trying to incorporate escape characters into stringstream, but I cannot figure out how to implement this correctly for the life of me. At the moment, I cannot even compile the program...
Type: Posts; User: Queue
I've been trying to incorporate escape characters into stringstream, but I cannot figure out how to implement this correctly for the life of me. At the moment, I cannot even compile the program...
Thanks for your post, grumpy. However, the sysadmin has limited our local access to the point where we cannot even set our own screensaver, much less password protect it.
I was looking more into...
Yes, you are correct. I can save things to a network drive, but I do not have access to the local registry.
The local machine is part of the network. However, I think the sysadmin placed quite a few...
Well, to clarify a bit, I do not have a local account on the machine. I logon via an account set up through Active Directory and connect to the domain. I'm quite positive that I do not have access to...
The workstations at my workplace do not allow for us to lock our computers, nor do they allow us installation access. Therefore, I am wondering if it is possible to reimplement the Windows Lock...
If I'm not mistaken, the compiler cannot locate the prototype for malloc, so you must add this somewhere in your code:
#include <stdlib.h>
After rethinking over the design, I believe that I may in fact implement the parser as a FSM. In addition to all the previous functionality, I believe that multiple wildcards may improve its...
I'm curious as to why you consider it a hack job. If the reason is simply the amount of time you put into it, that makes sense. Looking at the code, though, I must say I don't really see how it could...
Unfortunately, the parsing doesn't get much more complex than what I've shown thus far. Still, I'm very curious as to what a full-fledged FSM looks like code-wise (especially without the use of a...
Thanks for posting that, Dave_Sinkula. Of course, now that I've seen another way to accomplish the same goal, I'm curious to know why you've implemented some parts the way that you did.
Instead...
Ah, I misinterpreted your blue highlighting as a link. I still would be interested in how parse_field would be implemented, though.
Could you provide that link, so that I can understand how it would actually work?
Thanks, Salem. Any suggestions and/or criticism on the rest of the code?
Overview: parse_field acts like fgets, except while fgets returns lines, parse_field returns whitespace delimited fields. However, unlike fgets, which simply returns the next line, parse_field also...
I just realized that each field could possibly have more than just one ampersand. How would I take this into account if I were to modify post #6? A simple while loop would not work, as the memory...
Unfortunately, the reading must be in C to keep it consistent with the rest of the program. Prelude's post answered my question completely. Thanks everyone for all the help.
The only method I know of continually reallocates memory to a char* while adding the character to the last element. Personally, I want to avoid realloc if possible. Has anyone written a function...
Is it possible to pull one line at a time from a stream without specifying the buffer size (unlike in fgets)? Also, is there any way to store that line into a char*? Thanks.
Thanks, Dave_Sinkula, for the actual implementation. One quick question:
field = malloc(replen + len);should look more like
field = malloc(replen + len + 1);because of the null terminator, right?
That's definitely not difficult to change, but I'm having trouble coming up with the actual implementation and code for the '&' swap, even with the correct memory allocation.
Thanks, dwks. I understand how to implement the memory allocation part now, but I'm still stumped when it comes to implementing the actual replacement. Could you please clarify that a bit?
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int main(void) {
const char* line = "user1,user2,&,user4 group1,group2,group3 string1 string2 string3";
const char*...
So it's basically a style/personal choice? Thanks everyone for all the input.
strncpy(s3, s2, len);
sprintf(s3, "%.*s", len, s2);
while(len--) *s3++ = *s2++;
*s3 = 0;Which is most preferable?
How about
char s1[] = "This is an example sentence.";
char *start = s1;
while (*start != ' ') ++start;
char *end = start;
while (*end != ' ') ++end;
size_t len = end - start;
char *s3 =...