473,770 Members | 6,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help for the Unix Task.This is simple but i need help...Please help me....

4 New Member
Dear everybody,

I have to write a program that implements a real-time multicast calculator service. Users join a multicast group and are able to send equations to other clients for calculation - no separate server is needed. Calculations are sent in a single string to the multicast group and the result is returned once it has been calculated by a client in single string containing the equation and its result. The client must be able to calculate simple addition, subtraction, multiplication and division calculations. The required maximum amount of factors in an equation is 5. Clients are not required to implement removal of duplicate results.

For example if the client send a equation 2+3*2 then the server should return the result 8.
Thankyou in advance,
Nov 6 '06 #1
4 1857
srikpen
14 New Member
in perl you can do some thing like

@numTokens = split/\+\*\/\-/, $calcString

$numTokens[0] will contain you first operand and so on..

so basically look into regex and you can retrieve you operators as well as your
operands.
Nov 6 '06 #2
SijSaru13
4 New Member
in perl you can do some thing like

@numTokens = split/\+\*\/\-/, $calcString

$numTokens[0] will contain you first operand and so on..

so basically look into regex and you can retrieve you operators as well as your
operands.
Thanx for your suggestion ,but i have to do it in C .Please help me if you can.
Thanx..
Nov 7 '06 #3
steven
143 New Member
Thanx for your suggestion ,but i have to do it in C .Please help me if you can.
Thanx..
Why don't you start by showing people what have already come up with yourself. Surely you've made a start, right? I'm sure you're not the kind of person who comes to a forum expecting other people to give you the code... =]
Nov 7 '06 #4
ValHolla
8 New Member
if you are looking to do this in C. check out the man page for strtok

char *strtok(char *s1, const char *s2);

char *strtok_r(char *s1, const char *s2, char **lasts);
strtok()
The strtok() function can be used to break the string
pointed to by s1 into a sequence of tokens, each of which is
delimited by one or more characters from the string pointed
to by s2. The strtok() function considers the string s1 to
consist of a sequence of zero or more text tokens separated
by spans of one or more characters from the separator string
s2. The first call (with pointer s1 specified) returns a
pointer to the first character of the first token, and will
have written a null character into s1 immediately following
the returned token. The function keeps track of its position
in the string between separate calls, so that subsequent
calls (which must be made with the first argument being a
null pointer) will work through the string s1 immediately
following that token. In this way subsequent calls will work
through the string s1 until no tokens remain. The separator
string s2 may be different from call to call. When no token
remains in s1, a null pointer is returned.

strtok_r()
The strtok_r() function has the same functionality as
strtok() except that a pointer to a string placeholder lasts
must be supplied by the caller. The lasts pointer is to
keep track of the next substring in which to search for the
next token.
Mar 23 '07 #5

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

Similar topics

8
5481
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
22
3080
by: Ryan M | last post by:
I've been programming for a while, but most of my experience is on unix. How do C compilers work on operating systems that weren't written in C? And that have no libc? Compiling C on unix seems so easy. Everything in the code either goes right to machine code, or links to a C library (often libc) or links to the kernel. Are there libc equivalents on non-unix OSes? -- Using M2, Opera's revolutionary e-mail client:...
18
5651
by: Sharon | last post by:
is microsoft going to develop .Net for Unix? or at lest CLR for Unix? 10x
11
15427
by: Max | last post by:
I'm writing a program that needs to be able to create custom .job files and add them to the scheduled tasks folder. What I'd like to know is, what is the format of a .job file and how do I go about adding in all the data so that the task could run correctly? If that is something not so easy to do, then say I need a certain part of my program to execute on a schedule... How do I go about writing some internal scheduling routine that won't...
1
3721
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am attach this script files and inq files. I cant understand this error. Please suggest me. You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am online. Plz....Plz..Plz...
3
1924
by: Matthew Warren | last post by:
I have the following piece of code, taken from a bigger module, that even as I was writing I _knew_ there were better ways of doing it, using a parser or somesuch at least, but learning how wasn't as fun as coding it... And yes alarm bells went off when I found myself typing eval(), and I'm sure this is an 'unusual' use of for: else: . And I know it's not very robust. As an ex cuse/planation, this is what happens when you get an idea in...
0
5576
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
3
7003
by: Todd_Goselin | last post by:
Hello, I've got a problem that I can't fix by myself, I'm fairly new to programming in C and in Unix and so I'm having a tough time doing a simple task of converting a binary number to a string. Can anyone help me with that? Here is the problem: vals2 = ldap_get_values(ld,e,b);
4
1696
by: Guern1 | last post by:
Hi Need a bit of help here please to point me in the right direction. I have a java class file here which i wish from a menu item to open a web page which contains a help page. ] } else if (arg.equals(" Help Page")) { } else if (arg.equals("BrowserControl")) {
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.