Results 1 to 12 of 12

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: I just made my first application!

  1. #1
    Retired Moderator DoerrFan's Avatar
    Join Date
    Jul 2007
    Location
    Boston
    Posts
    2,290
    Thanks
    143
    Thanked 461 Times in 229 Posts

    Default I just made my first application!
    Hey guys i just made my first application, its a calculator that runs in terminal, it adds, subtracts multiplies, and divides, it isn't much, but im excited!
    Its in C, for some reason Objective -C doesn't look like a good starting point to learn development.
    One question though, after i enter 6 + 6 or something, it logs out after, what command would i use to restart it?

    Thanks, just had to share

  2. The Following User Says Thank You to DoerrFan For This Useful Post:

    luiz (2008-03-24)

  3. #2
    Cool, I would like to see your code... possible?

    I am triying to learn ... wanna help me?
    In Costa Rica Beaches w/ my unix box.

  4. #3
    Retired Moderator DoerrFan's Avatar
    Join Date
    Jul 2007
    Location
    Boston
    Posts
    2,290
    Thanks
    143
    Thanked 461 Times in 229 Posts

    Quote Originally Posted by drunix View Post
    Cool, I would like to see your code... possible?

    I am triying to learn ... wanna help me?
    Sure, here:
    Calculate.c
    /*
    * Calculate.c
    * Calculator
    *
    * Created by Jon Makkinje on 3/21/08.
    * Copyright 2008 All rights reserved.
    *
    */

    #include "Calculate.h"

    #include <stdio.h>
    #include <stdlib.h>

    int calculate(int a, int b, char operator)
    {
    int result;

    switch (operator) {
    case '+':
    result = a + b;
    break;
    case '-':
    result = a - b;
    break;
    case '*':
    result = a * b;
    break;
    case '/':
    result = a / b;
    break;
    default:
    printf("Unknown operator: %c/n", operator);

    }

    return result;
    }

    Calculate.h
    int calculate(int a, int b, char operator);

    main.c
    #include <stdio.h>
    #include <stdlib.h>

    #include "Calculate.h"

    int main (int argc, const char * argv[])
    {
    int a, b, count, answer;
    char op;

    // print the prompt
    printf("Enter an expression; ");

    // get the expression
    count = scanf("%d %c %d", &a, &op, &b);
    if (count!=3) {
    printf("Bad expression\n");
    return 1;

    }

    // perform the computation
    answer = calculate(a, b, op);

    // print the answer
    printf("%d %c %d = %d\n", a, op, b, answer);

    return 0;
    }

  5. #4
    wow that's great news ! I'm actually happy for you lol

    here's to more complex apps in the future..
    If I help you out, help me out by clicking the button

  6. #5
    Retired Moderator DoerrFan's Avatar
    Join Date
    Jul 2007
    Location
    Boston
    Posts
    2,290
    Thanks
    143
    Thanked 461 Times in 229 Posts

    Quote Originally Posted by TheHK View Post
    wow that's great news ! I'm actually happy for you lol

    here's to more complex apps in the future..
    Yeah, im hoping to make iPhone apps xD

  7. #6
    I see you are using C++ instead of Obj-C. I know C++ really well, but I want to start learning Obj-C...
    Check out Media Database for the iPhone!
    http://www.djkev.com/apps/iPhone.php

  8. #7
    Livin the iPhone Life heath_rox's Avatar
    Join Date
    Nov 2007
    Location
    Liberty City
    Posts
    1,292
    Thanks
    120
    Thanked 205 Times in 117 Posts

    congratulations
    "Its better to be a pirate than join the navy"Steve Jobs

  9. #8
    Retired Moderator DoerrFan's Avatar
    Join Date
    Jul 2007
    Location
    Boston
    Posts
    2,290
    Thanks
    143
    Thanked 461 Times in 229 Posts

    Quote Originally Posted by Kev1000000 View Post
    I see you are using C++ instead of Obj-C. I know C++ really well, but I want to start learning Obj-C...
    Yeah i want to to, but it doesn't seem like a good starting point for some reason for a first time developer, i want to learn C then Objective C, just need to learn about OOP.

  10. #9
    My iPhone is a Part of Me
    Join Date
    Jul 2007
    Location
    Orlando FL
    Posts
    767
    Thanks
    17
    Thanked 23 Times in 22 Posts

    ::bows down:: nice your on the path i sure would like to fallow. im stucking waiting till i grad. form HS, and get a pretty macbook pro

  11. #10
    1. You can compile this with the Windows toolchain and run it on a jailbroken phone.

    2. You don't need to restart, you want to do what is called a Read-Eval-Print loop, which means you need an exit command (or let an error do exit) and put the scan in a loop:

    while (1) {
    puts("Enter an expression: ");

    count = scanf("%d %c %d", &a, &op, &b);
    if (count != 3) {
    puts("Bad expression\n");
    return 1;
    }

    answer = calculate(a, b, op);

    printf("%d %c %d = %d\n", a, op, b, answer);
    }

    (Personal preference - don't comment the obvious.)
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage

  12. The Following User Says Thank You to NetMage For This Useful Post:

    DoerrFan (2008-03-27)

  13. #11
    iPhone? More like MyPhone screamo's Avatar
    Join Date
    Jan 2008
    Location
    Vegas
    Posts
    117
    Thanks
    12
    Thanked 10 Times in 7 Posts

    dang that looks confusing, good work though, your making progress!
    Please don't stop the music

  14. The Following User Says Thank You to screamo For This Useful Post:

    Mars478 (2008-03-27)

  15. #12
    Retired Moderator DoerrFan's Avatar
    Join Date
    Jul 2007
    Location
    Boston
    Posts
    2,290
    Thanks
    143
    Thanked 461 Times in 229 Posts

    Quote Originally Posted by NetMage View Post
    1. You can compile this with the Windows toolchain and run it on a jailbroken phone.

    2. You don't need to restart, you want to do what is called a Read-Eval-Print loop, which means you need an exit command (or let an error do exit) and put the scan in a loop:

    while (1) {
    puts("Enter an expression: ");

    count = scanf("%d %c %d", &a, &op, &b);
    if (count != 3) {
    puts("Bad expressionn");
    return 1;
    }

    answer = calculate(a, b, op);

    printf("%d %c %d = %dn", a, op, b, answer);
    }

    (Personal preference - don't comment the obvious.)
    Thanks!

  16. The Following User Says Thank You to DoerrFan For This Useful Post:

    Mars478 (2008-03-27)

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •