Now I need to write a version of getword that properly handles underscores, string constants, comments or preprocessor control lines. I just don't understand now how to process, I would be looking...
Type: Posts; User: coder222
Now I need to write a version of getword that properly handles underscores, string constants, comments or preprocessor control lines. I just don't understand now how to process, I would be looking...
Something like this, perhaps?
int getword(char *word, int lim)
{
int c, getch(void);
Hello, I don't obviously understand how this function works:
int getword(char *word, int lim)
{
int c, getch(void);
I'm confused. How can I attempt the exercises if the code presented in the book doesn't even compile?
It should convert a C declaration into words, like this:
char ** argv
argv: pointer to pointer to char
The program can also be found here <LinkSnippedDueToCopyright>
I need to get...
When I enter a declarator, for example char**argv produces the error message:
syntax error
c: c
syntax error
c: c
syntax error
c: c
So now I'm working with the K&R code again and trying to get it work successfully. Any help is appreciated to get this working, thanks.
here is the code:
#include <stdio.h>
#include...
hello,
I have been trying to understand this function, there is still a few things confusing me. First, what are those weird statements like return token type = BRACKETS for? I have never seen...
Hello, I came across this function when reading the K&R and here is my comments on the source. Am I on the right track? Also, I'm not sure what is ungetch here or how it's supposed to work.
...
Hello, I would like to make a snake game. Here is what I have in mind:
struct dot // snake position
{
int x;
int y;
}
Sorry, I did not provide enough information. The book I'm currently reading never goes over the Spiral rule. I think it is possible to parse declarations according to this grammar?
dcl: ...
Hi,
My C programming continues as I'm trying to understand complicated declarations.
Can anyone point out how to parse a declaration like this:
char (*( *x() )[] ) ()
Or what is the general...
Hello, I'm doing the K&R again.
So what I need is some sort of help with this exercise:
Modify the program detab to accept a list of tab stops as argument.
Here is what I think it should go...
Thank you @Salem. Can you be more detailed about the code that should be written? It's a bit of time I have written the above code, and my C programming is also rusty (Not to mention the breaks that...
Here is the description: Modify the program detab (written as exercises in Chapter 1) to accept a list of tab stops as arguments. Use the default tab settings if there are no arguments.
What I...
@Anduril great explanation. Here is a simple test driver: http://coliru.stacked-crooked.com/a/db0fdb9ca3173168
I mean simple, no error handling or anything but I think it shows that my function is...
I think this is in other words what Anduril said:
What is actually happening here I'm dereferencing the pointers that are passed to the function so that I get copies of them and can modify...
@Whiteflags:
Perhaps this is what you intended?
for (n = 1; n < argc && argv[n][0] == '-'; ++n) {
switch (argv[n][1]) {
case 'n':
printf("numeric = %d, reverse = %d\n", numeric, reverse);
while(argc > 1 && argv[n][0] == '-') /* Printf statements inside while loop? */
switch(argv[n][1]) { ...
Yes. It prints the arguments in the order in which they appear to, and doesn't do any sorting. For example,
argc = 1, n = 0
argv[0] = './fast'
defghi
abcd
efg
I haven't made any table yet, this is the right way to go for the command line arguments?
while(argc > 1 && argv[n][0] == '-')
switch(argv[n][1]) {
case 'n':
...
So I plan to do the flag parsing myself. argv[n][0] or *argv[0] is the first character of an argument string. That's why I changed line 34 to argv[n][1] in the switch statement.
I'm afraid I...
I'm not getting the reverse flag work please help here is my updated code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
> I also compile with maximum warning level and don't get any error/warning.
This is what I came up with the comparison function:
int lexiographic_descending_sorter (const char *s1,...
The task is as following: Modify the sort program to handle a -r flag, which indicates sorting in reverse (decreasing) order. Be sure that
-r works with -n.
I think the interest is the fourth...