Sponsored Content
Full Discussion: The Terminal on Mac: Coding
Operating Systems OS X (Apple) The Terminal on Mac: Coding Post 302939019 by 1negroup on Saturday 21st of March 2015 01:07:49 AM
Old 03-21-2015
The Terminal on Mac: Coding

So found this C code online and need to compile it in Terminal on Mac.
Here is the code:
Code:
#include <stdio.h>
#include <math.h>
 
int option;
char q;
int number;
int currentsum;
int value;
 
void calc()
{
     printf("\t\t\t\t\tBegin\n"); // says begin in top middle of screen
     option = 0; number = 0; currentsum = 0; value = 0;
     while(1){
              value = getchar(); // gets user input and sets equal to value
              if (value >= '0' && value <= '9')
              {
                 number = number*10 + (value - '0'); /* a way of reading the "values" left to right. If someone puts in 729 as their first number then it will go across
              and do number = 0*10 (because number was set equal to 0) + 7. then it goes through again. number is now 7 so it goes through and does 7*10 + 2 thus making
              72. Number is now 72 which means it goes 72*10 + 9 making number 729. It will follow this process if the input is a number 1-9*/
              }
              if (value == '+' || value == '-' || value == '*' || value == '/' || value == '^' || value == '=' || value == '\n')
              {
                   if(value == '+') currentsum = currentsum + number; // if I come across one of these symbols then it performs the operation described
                   if(value == '-') currentsum = currentsum - number;
                   if(value == '*') currentsum = currentsum * number;
                   if(value == '/') currentsum = currentsum / number;
                   if(value == '^') currentsum = pow(currentsum, number);
                   if(value == '=') printf(currentsum);  // when it reads an equal sign or a new line it displays the result of the equation.
                   if(value == '\n') printf(currentsum);
              }
              else break; // come across any other symbols or characters break the loop     
             }
}
int main()
{
    system("title Calculator"); // titles windo "Calculator
    system("color 1A"); // makes background blue
    calc(); // goes to void calc
    system("pause");
    scanf("%c",&q);
    if( q == 'q')exit(0);
}

Now just to let you know i do not want to use anything else to compile it except for the Terminal.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Mac OS X/UNIX/Terminal Question

Hey everyone I'm new to UNIX due to the new Mac OS X operating system and would like some help. I'm trying to send an email via the UNIX-Shell-Terminal i Mac OS X, (it's called darwin) How do I do that? When I enter the Command mail I can send messages to root and with the command -forward... (4 Replies)
Discussion started by: onkel
4 Replies

2. UNIX for Dummies Questions & Answers

Running Terminal and/or X-Windows in Mac OS X

Quick question: When I load up Terminal or X-Windows on my Mac, and the prompt comes up...what folder am I starting in? (2 Replies)
Discussion started by: liquidcross
2 Replies

3. Shell Programming and Scripting

Coding on my Mac

I would like to start coding on my mac, but I'm getting an error when I attempt to execute my script -bash : testscript: command not found I have verified that the #! line points to the correct directory. If you have some insight it would be greatly appreciated! - D (1 Reply)
Discussion started by: DKNUCKLES
1 Replies

4. UNIX for Dummies Questions & Answers

Problems installing a program through Terminal in Mac OS X

Hey all.. I have a problem with the BitTorrent client called Deluge. (Deluge BitTorrent Client). Followed the guide on their homepage, but can't get it to work. First of all I have installed Xcode Tools 3.0 and MacPorts. I did the "sudo port install deluge" command, and all packages seemed to... (1 Reply)
Discussion started by: Sixmax
1 Replies

5. UNIX for Dummies Questions & Answers

How can I list all users from a terminal window in MAC?

Hi, What command is needed to find all or certain users from a terminal window in MAC OS X 10.5? Where is a list of categorized commands that could help me find answers similar to this particular question? Thanks. Juan Dent (1 Reply)
Discussion started by: Juan Dent
1 Replies

6. OS X (Apple)

New to Mac OS X Terminal

Hi everyone. I'm new to using the Terminal and was just wondering if anyone had a link to perhaps a list of commands. And tips on some useful websites to visit or books to read. Oh and is there a way to delete just part of the Terminal's history? If so what is the command? Thanks :) (2 Replies)
Discussion started by: xsemperidem5
2 Replies

7. UNIX for Dummies Questions & Answers

How to create new users on my mac from the terminal

I finally got how to su - in my mac from the terminal. Now I would like to be able to add new users. useradd -m -d ..... doesn't seem to work. (1 Reply)
Discussion started by: bigmac18
1 Replies

8. Shell Programming and Scripting

How to checkout from SVN using Terminal in Mac OS X?

Hi, I am new for SVN. Earlier I have been using CVS. When I checkout the code from SVN using Eclipse, the size of the source code checked out is 612MB. But when I try to checkout from terminal, from my 5.8 branch , the checked out source code's size is only 312.1 MB. Can anyone tell me... (0 Replies)
Discussion started by: Afreen
0 Replies

9. UNIX for Advanced & Expert Users

close a mac terminal

Is there a trick to closing a mac terminal with a command? I would think you could just type exit into your terminal but that doesn't work. I also tried quit and close just for the hell of it and that didn't work either. Does anyone know what the command is? (1 Reply)
Discussion started by: cokedude
1 Replies

10. Open Source

The Terminal on Mac OS X

Does anyone know the differences in commands when it come to Linux and Mac OS X? I'm wanting to know if I use "this" command in Linux and It doesn't work in Mac then what command is equivalent to the one in Linux. Example Ctrl+Alt+f2 switches to (tty2) so what equivalent switches to ttys2 on Mac? (13 Replies)
Discussion started by: 1negroup
13 Replies
PERLMACOS(1)						 Perl Programmers Reference Guide					      PERLMACOS(1)

NAME
README.macos - Perl under Mac OS (Classic) SYNOPSIS
This document briefly describes perl under Mac OS (Classic). If you are running perl under Mac OS X, you don't want to be here (unless you are in the Classic environment under Mac OS X). When we say "Mac OS" below, we mean Mac OS 7, 8, and 9, and not Mac OS X. DESCRIPTION
The latest perl source itself builds on Mac OS, with some additional pieces. Support for Mac OS is now in the perl core, and MacPerl is kept in close sync with regular perl releases. To build perl for Mac OS (as an MPW tool), you will need the addition of the macos subdirectory, distributed separately. It includes extra source files, config files, and make files. It also includes extra Mac-specific modules. To build the MacPerl application, you will also need the macperl directory, which includes the source files for creating the application itself. All of this is available from the development site, via HTTP (in the MacPerl Installer, which includes all the source and binaries) and anonymous CVS. http://dev.macperl.org/ The source is also in the main perl repository in the macperl branch (the 5.6 source is in the maint-5.6/macperl branch). You will also need compilers and libraries, all of them freely available. These are linked to from the SourceForge site. Go that site for all things having to do with MacPerl development. MacPerl 5.6.1 and later are supported on Mac OS 8.1 and later, for 68040 and PowerPC architectures. The MPW tool may be used on Mac OS 7.5.5 and 68030 computers. MacPerl 5.2.0r4 is also available, on the CPAN and on SourceForge. It is based on perl 5.004, and works with Mac OS 7.5.5 and 68030 com- puters. AUTHOR
perl was ported to Mac OS by Matthias Neeracher <neeracher@mac.com>. It is currently maintained by Chris Nandor <pudge@pobox.com>. DATE
Last modified 2002.05.02. perl v5.8.0 2003-02-18 PERLMACOS(1)
All times are GMT -4. The time now is 02:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy