473,322 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem in running program but the code compiles succesfully

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. char LA;
  7. char* str;
  8. void R(int R_i, int& R_s);
  9. void Digit(int& Digit_val);
  10. void input_error();
  11.  
  12. char token() 
  13. {
  14.      return *str++; 
  15.      }
  16.  
  17. void Num(int& Num_val)
  18. {
  19.   int Digit_value, R_i, R_s;
  20.   Digit(Digit_value);
  21.   R_i = Digit_value;
  22.   R(R_i,R_s);
  23.   Num_val = R_s;
  24. }
  25.  
  26. void R(int R_i, int& R_s)
  27. {
  28.   int Digit_value, R1_i,R1_s;
  29.   if ( LA == '\0' ) 
  30.     R_s = R_i;
  31.   else
  32.   {
  33.     Digit(Digit_value);
  34.     R1_i = 3* R_i + Digit_value;
  35.     R(R1_i,R1_s);
  36.     R_s = R1_s;
  37.   }
  38. }
  39.  
  40. void Digit(int& Digit_val)
  41. {
  42.   LA = token();
  43.   if ( LA == '0' ) Digit_val = 1;
  44.   else if ( LA == '1' ) Digit_val = 0;
  45.   else if ( LA == '\0' ) return;
  46.   else input_error();
  47. }
  48.  
  49.  
  50. void input_error() 
  51. { cout << "unacceptable character" << endl; }
  52.  
  53. int main(int argc, char *argv[])
  54.   str = argv[1];
  55.   int str_value;
  56.   cout << str << endl;  
  57.   Num(str_value);
  58.   cout << "value = " << str_value << endl;
  59. }
  60.  
Nov 17 '08 #1
4 1173
Ganon11
3,652 Expert 2GB
Do you want to tell us what this program does? What is should do? Where the error is? Or should we just guess based on the code you've posted?
Nov 18 '08 #2
Do you want to tell us what this program does? What is should do? Where the error is? Or should we just guess based on the code you've posted?
it solves the SDT(syntax directed translation)
we have to solve
Num -> Digit Num.val := Digit.val
Num -> Num1 Digit Num.val := 3*Num1.val + D.val
Digit -> 0 Digit.val := 1
Digit -> 1 Digit.val := 0
i have written this program it compiles succesful but when i try it to run my Dev C++ compiler says "Program stop working" i think there might be linking error
Nov 18 '08 #3
r035198x
13,262 8TB
Put some cout statements to decide when the error is being given.
e.g in your main you are assuming that argv will have at least 2 entries because you are accessing argv[1]. Are you sure that it has at least 2 entries?
Nov 18 '08 #4
Put some cout statements to decide when the error is being given.
e.g in your main you are assuming that argv will have at least 2 entries because you are accessing argv[1]. Are you sure that it has at least 2 entries?
i figured ........now its working
Nov 18 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Nyul | last post by:
Gurus, I have a verb big problem which I'm unable to explain. We have a DB2 V6.1.0 on AIX 4.3 I want to make a C stored procedure which at the end will be called by a PHP script. The...
37
by: Patrik Huber | last post by:
Hello! I got the following Code in Assembler (NASM), which prints out "5" in realmode: mov ax, 0xB800 mov es, ax mov byte , '5' I want to do the same in gcc now, but I'm stuck. GCC...
1
by: Nedu N | last post by:
Hi All, I am facing a typical problem in my .NET application with the pop-up script messages. The thing is that its working fine when i run on my development machine but not running in expected...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
8
by: Gary | last post by:
I'm using an Act database. I was stuck on this a year ago and am still having trouble. I have three bits of code like so : - act.CActAppObj objACT = new act.CActAppObj(); act.CAIBaseView...
10
by: Clayton | last post by:
Hi all, I'm trying to develop a server that listens to incoming calls using the asycnhronous methods BeginAccept / EndAccept. I start the server (till this point it is ok) and few seconds later...
0
by: james.mcdonagh | last post by:
Hi I am a newbie using nAnt for .net 2.0. As such I have not come across this bug before, and I would be happy of any help that you may be able to provide. In order to help I have included the...
2
by: Praesidium | last post by:
I'm having a bit of a problem running a C program I'm working on (compiled in cygwin). There's a way to go, as I'm intent on making sure each bit works before moving on to the next. As it appears...
1
by: Chuck Chopp | last post by:
I have some code that is being built on the following: Windows Server 2003, both 32-bit & 64-bit editions Windows Vista, both 32-bit & 64-bit editions Windows Server 2008, both 32-bit & 64-bit...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.