Search:

Type: Posts; User: mlsrar

Search: Search took 0.01 seconds.

  1. I declare it as a character array: char...

    I declare it as a character array:



    char query_word[MAX_LENGTH];
    welcome();
    FILE *file_ptr;
    char word[MAX_LENGTH];
  2. I apologize for my misdirection. I've always...

    I apologize for my misdirection. I've always held true to the mantra of man-pages, and being told never to use strtok with constant strings. If it's the closest equivalent of chomp, then I'll use...
  3. Dealing with CR (newline) from fopen in search.

    I'm trying to compensate for the carriage returns given to a program both from a file read in, or a word entered by a user followed by a carriage return.

    The search function doesn't appear to deal...
  4. Replies
    36
    Views
    5,654

    I'm learning... The compilation is throwing me...

    I'm learning...

    The compilation is throwing me a syntax error within the calculate function:



    float calculate(char *postfix)
    {
    char *operation;
    stack_type stk;
  5. As in the way I"m currently implementing it? ...

    As in the way I"m currently implementing it?


    char input[STACKSIZE];
    stack_type stk;
    int i=0;
    stk.top = -1; /* Initialize the stack to empty */
    int sum;
    ...
  6. I haven't learned about strtol yet, so I'm not...

    I haven't learned about strtol yet, so I'm not really familiar with it. I've heard its an evolution of atoi, which I have been told is rather nefarious. (edited to say...I'm not expecting to have it...
  7. else if (strcmp(input, "quit\n") == 0) { ...

    else if (strcmp(input, "quit\n") == 0)
    {
    printf("Time to quit...goodbye!\n");
    exit(0);
    }
    }

    If quit is input, i break out of the loop.

    It's a basic postfix...
  8. Again, my terminal and opera aren't cooperating. ...

    Again, my terminal and opera aren't cooperating. Return 0 is there.

    I have no need to declare input as a pointer. It compiles and executes, but always returns 2 as a sum:



    int main(void)...
  9. No, I think I missed it in the cut/paste...it is...

    No, I think I missed it in the cut/paste...it is in there. I'm just doing a single-digit implementation, as I'm learning it, and didn't want to tackle the complications. It IS supposed to use...
  10. int is_operator(int x) { if(x == '+' || x ==...

    int is_operator(int x)
    {
    if(x == '+' || x == '-' || x =='/' || x == '*' || x == '%')
    return x;
    }


    I am assuming single-digit input, but was not assuming spaces. Tabstop, thanks for...
  11. Stack operations from switch statement elements

    I have a program that compiles with no errors or warnings, but the logic is flawed. It is a postfix calculator...I have a default in the switch statement that is supposed to match non-operator input...
  12. Replies
    36
    Views
    5,654

    Compilation with no errors...yay! Thanks for the...

    Compilation with no errors...yay! Thanks for the wiki again.

    I'm declaring an array of items from the user-input to push on to the stack to calculate. Inside of a for-loop, I believe I have...
  13. Replies
    36
    Views
    5,654

    Thanks for the wiki... I do not to change any...

    Thanks for the wiki...

    I do not to change any constant data, so I will safely avoid using a constant. In the example from the wiki: (Thanks btw)

    char[] str = "This is my string";
    str[5] =...
  14. Replies
    36
    Views
    5,654

    const char* input[STKSIZE]; Would be a pointer...

    const char* input[STKSIZE];

    Would be a pointer to constant data, the input from the user, which I will need to reference as i pop/push from the stack. I would need to use it to access the...
  15. Replies
    36
    Views
    5,654

    Compilation with warnings: calc.c:38: warning:...

    Compilation with warnings:

    calc.c:38: warning: passing arg 1 of `fgets' from incompatible pointer type
    calc.c:40: warning: passing arg 1 of `strcmp' from incompatible pointer type
    calc.c:40:...
  16. Replies
    36
    Views
    5,654

    Yes, I am learning C. In using double-quotes, I...

    Yes, I am learning C. In using double-quotes, I still receive the aforementioned warning during compilation and it segfaults regardless of input.

    I wouldn't think I could legally declare
    ...
  17. Replies
    36
    Views
    5,654

    passing arg 2 of `strcmp' makes pointer from...

    passing arg 2 of `strcmp' makes pointer from integer without a cast

    That's why I used the single quotes.
  18. Replies
    36
    Views
    5,654

    OK, that's fair, and, here's my solution that...

    OK, that's fair, and, here's my solution that now seg-faults (PS...any good tutorials on gdb?)



    while (strcmp(input, 'quit' == 0)) {

    for (i=0; i<strlen(input); i++) {
    ...
  19. Replies
    36
    Views
    5,654

    Would it be legal to define a case statement to...

    Would it be legal to define a case statement to compare instead?

    case (strcmp(input, "quit" !=0)):
    printf("Goodbye!\n");
    return 0;
  20. Replies
    36
    Views
    5,654

    while(strcmp(input, "quit" != 0) { Removed...

    while(strcmp(input, "quit" != 0) {


    Removed duplicate push functions (bad copy/paste)...still same result? It loops through 256 times for some reason?
  21. Replies
    36
    Views
    5,654

    Overflow in Stack Counter

    Program compiles successfully, as I am trying to implement the timeless postfix algorithm using a stack.

    It seems to, no matter what input I'm using, loop through 256 times until it encounters...
Results 1 to 21 of 21