Click here to Skip to main content
14,835,488 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Convert string name to Control ID Name Pin
Richard MacCutchan17-May-16 22:16
mveRichard MacCutchan17-May-16 22:16 
GeneralRe: Convert string name to Control ID Name Pin
002comp17-May-16 22:19
Member002comp17-May-16 22:19 
GeneralRe: Convert string name to Control ID Name Pin
Richard MacCutchan17-May-16 22:42
mveRichard MacCutchan17-May-16 22:42 
GeneralRe: Convert string name to Control ID Name Pin
leon de boer18-May-16 19:36
Memberleon de boer18-May-16 19:36 
AnswerRe: Convert string name to Control ID Name Pin
leon de boer18-May-16 19:51
Memberleon de boer18-May-16 19:51 
AnswerRe: Convert string name to Control ID Name Pin
Gerry Schmitz19-May-16 5:54
mveGerry Schmitz19-May-16 5:54 
SuggestionRe: Convert string name to Control ID Name Pin
Krishnakumartg21-Sep-16 19:57
MemberKrishnakumartg21-Sep-16 19:57 
QuestionRPN notation in C Pin
Member 1252915917-May-16 6:19
MemberMember 1252915917-May-16 6:19 
Hello, I am trying to code a program which evaluates expressions in reverse polish notations. For now, it should work only with numbers and operands ( +, -, * and / ).

Here is the code I have written:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <conio.h>
#define MAX 41

 int t, i, v1, v2;
 int top = -1;
 char seq[40];
 char rpn[40];
 char fin[40];
int main()
{
  printf("introduce the numbers and opreands in rpn \n");
 fgets(seq,40,stdin);
 
 t=strlen(seq);
 
 for (i=0;i<=t;i++)
 if (isdigit(seq[i]))
 {
     Push(rpn, seq[i]);
 }
 if (ispunct(seq[i]));
 
    v1=pop(rpn);
    v2=pop(rpn);
 
    if (seq[i] = '+');
        push(fin, v1+v2);
    if (seq[i] = '-');
        push(fin, v1-v2);
    if (seq[i] = '*');
        push(fin, v1*v2);
    if (seq[i] = '/');
        push(fin, v1/v2);
 
printf(fin);
}
 
int isempty() {
 
   if(top == -1)
      return 1;
   else
      return 0;
}
 
int isfull() {
 
   if(top == MAX)
      return 1;
   else
      return 0;
}
 
int peek() {
   return seq[top];
}
 

int pop() {
   int data;
 
   if(!isempty()) {
      data = seq[top];
      top = top - 1;
      return data;
   }else {
      printf("Could not retrieve data, Stack is empty.\n");
   }
}
 
int push(int data) {
 
   if(!isfull()) {
      top = top + 1;
      seq[top] = data;
   }else {
      printf("Could not insert data, Stack is full.\n");
   }
}


There are, I think, some big mistakes i can't solve by myself, since im a beginner in programming. I have searched for a solution on the internet, but i don't truly understand them.

The idea of my code is that the user types some numbers and operands like this: 2 3 +. In this case, the program should add 2 and 3 in a stack and when it reads and operator, pop the lasts 2 numbers on the pile and do the corresponding opperation.

When i build it I have this errors:
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
C:\Users\Jordi\Documents\RPN.o:RPN.c|| undefined reference to `Push|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


modified 17-May-16 13:03pm.

GeneralRe: RPN notation in C Pin
harold aptroot17-May-16 6:29
Memberharold aptroot17-May-16 6:29 
GeneralRe: RPN notation in C Pin
Member 1252915917-May-16 6:57
MemberMember 1252915917-May-16 6:57 
GeneralRe: RPN notation in C Pin
harold aptroot17-May-16 7:03
Memberharold aptroot17-May-16 7:03 
GeneralRe: RPN notation in C Pin
jeron117-May-16 7:29
Memberjeron117-May-16 7:29 
GeneralRe: RPN notation in C Pin
David Crow17-May-16 8:14
MemberDavid Crow17-May-16 8:14 
AnswerRe: RPN notation in C Pin
Richard MacCutchan17-May-16 20:50
mveRichard MacCutchan17-May-16 20:50 
QuestionPass by pointer not working Pin
Joe Smith IX15-May-16 5:52
MemberJoe Smith IX15-May-16 5:52 
AnswerRe: Pass by pointer not working Pin
Victor Nijegorodov15-May-16 10:58
MemberVictor Nijegorodov15-May-16 10:58 
GeneralRe: Pass by pointer not working Pin
Joe Smith IX17-May-16 8:34
MemberJoe Smith IX17-May-16 8:34 
AnswerRe: Pass by pointer not working [fixed] Pin
CPallini15-May-16 22:08
mveCPallini15-May-16 22:08 
GeneralRe: Pass by pointer not working Pin
Joe Smith IX17-May-16 8:25
MemberJoe Smith IX17-May-16 8:25 
GeneralRe: Pass by pointer not working Pin
CPallini17-May-16 9:58
mveCPallini17-May-16 9:58 
QuestionC string operations Pin
Member 1096409913-May-16 5:47
MemberMember 1096409913-May-16 5:47 
AnswerRe: C string operations Pin
Richard MacCutchan13-May-16 6:10
mveRichard MacCutchan13-May-16 6:10 
GeneralRe: C string operations Pin
Chris Losinger13-May-16 6:37
professionalChris Losinger13-May-16 6:37 
GeneralRe: C string operations Pin
Richard MacCutchan13-May-16 6:43
mveRichard MacCutchan13-May-16 6:43 
GeneralRe: C string operations Pin
Member 1256233616-Jun-16 12:40
MemberMember 1256233616-Jun-16 12:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.