I declare it as a character array:
char query_word[MAX_LENGTH];
welcome();
FILE *file_ptr;
char word[MAX_LENGTH];
Type: Posts; User: mlsrar
I declare it as a character array:
char query_word[MAX_LENGTH];
welcome();
FILE *file_ptr;
char word[MAX_LENGTH];
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...
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...
I'm learning...
The compilation is throwing me a syntax error within the calculate function:
float calculate(char *postfix)
{
char *operation;
stack_type stk;
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;
...
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...
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...
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)...
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...
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...
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...
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...
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] =...
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...
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:...
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
...
passing arg 2 of `strcmp' makes pointer from integer without a cast
That's why I used the single quotes.
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++) {
...
Would it be legal to define a case statement to compare instead?
case (strcmp(input, "quit" !=0)):
printf("Goodbye!\n");
return 0;
while(strcmp(input, "quit" != 0) {
Removed duplicate push functions (bad copy/paste)...still same result? It loops through 256 times for some reason?
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...