The ModMyTM Family of Sites:
ModMyMotoModMyiModMyGphone




 
 
Register or Connect with Facebook

Discuss AppStore Apps | Browse / Search Cydia | MMi Cydia Stats




  Apple Forums & iPhone Forums, Mods, Hacks, News, Themes, Downloads, and more! | ModMyi.com > 3rd Party Apps For iPhone | iPod Touch > iPhone / iPod Touch SDK | Development Discussion
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 03-23-2008, 05:25 PM
DoerrFan's Avatar
Moderator
 
Join Date: Jul 2007
Device + Firmware: iPhone 3.0
Operating System: Snow Leopard, Windows 7, and Ubuntu.
Location: Massachusetts
Posts: 2,279
Thanks: 131
Thanked 450 Times in 227 Posts
Send a message via AIM to DoerrFan Send a message via Skype™ to DoerrFan
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
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following User Says Thank You to DoerrFan For This Useful Post:
luiz (03-24-2008)
  #2  
Old 03-24-2008, 12:27 AM
drunix's Avatar
Green Apple
 
Join Date: Oct 2007
Posts: 52
Thanks: 13
Thanked 6 Times in 4 Posts

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

I am triying to learn ... wanna help me?
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #3  
Old 03-24-2008, 02:17 PM
DoerrFan's Avatar
Moderator
 
Join Date: Jul 2007
Device + Firmware: iPhone 3.0
Operating System: Snow Leopard, Windows 7, and Ubuntu.
Location: Massachusetts
Posts: 2,279
Thanks: 131
Thanked 450 Times in 227 Posts
Send a message via AIM to DoerrFan Send a message via Skype™ to DoerrFan

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;
}
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #4  
Old 03-24-2008, 02:57 PM
iPhoneaholic
 
Join Date: Oct 2007
Posts: 351
Thanks: 29
Thanked 106 Times in 69 Posts

wow that's great news ! I'm actually happy for you lol

here's to more complex apps in the future..
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #5  
Old 03-24-2008, 03:25 PM
DoerrFan's Avatar
Moderator
 
Join Date: Jul 2007
Device + Firmware: iPhone 3.0
Operating System: Snow Leopard, Windows 7, and Ubuntu.
Location: Massachusetts
Posts: 2,279
Thanks: 131
Thanked 450 Times in 227 Posts
Send a message via AIM to DoerrFan Send a message via Skype™ to DoerrFan

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
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #6  
Old 03-24-2008, 11:27 PM
What's Jailbreak?
 
Join Date: Aug 2007
Location: Southfield, MI
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts

I see you are using C++ instead of Obj-C. I know C++ really well, but I want to start learning Obj-C...
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #7  
Old 03-25-2008, 04:49 AM
heath_rox's Avatar
Livin the iPhone Life
 
Join Date: Nov 2007
Device + Firmware: 1st Gen IPhone all sizes/unlocked 2.0
Operating System: OSX Leopard
Location: Liberty City
Posts: 1,289
Thanks: 117
Thanked 169 Times in 116 Posts
Send a message via MSN to heath_rox

congratulations
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #8  
Old 03-25-2008, 08:23 PM
DoerrFan's Avatar
Moderator
 
Join Date: Jul 2007
Device + Firmware: iPhone 3.0
Operating System: Snow Leopard, Windows 7, and Ubuntu.
Location: Massachusetts
Posts: 2,279
Thanks: 131
Thanked 450 Times in 227 Posts
Send a message via AIM to DoerrFan Send a message via Skype™ to DoerrFan

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.
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #9  
Old 03-26-2008, 05:55 PM
My iPhone is a Part of Me
 
Join Date: Jul 2007
Device + Firmware: 3G 2.1
Operating System: XP/OSX 10
Location: Orlando FL
Posts: 765
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
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #10  
Old 03-26-2008, 06:08 PM
NetMage's Avatar
Developer
 
Join Date: Aug 2007
Device + Firmware: iPhone 2.2.0
Operating System: Windows XP / OS X
Location: Virginia
Posts: 1,231
Thanks: 45
Thanked 202 Times in 162 Posts

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.)
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following User Says Thank You to NetMage For This Useful Post:
DoerrFan (03-26-2008)
  #11  
Old 03-26-2008, 07:05 PM
screamo's Avatar
iPhone? More like MyPhone
 
Join Date: Jan 2008
Device + Firmware: iTouch + 1.1.4
Operating System: Windows XP
Location: Vegas
Posts: 117
Thanks: 12
Thanked 9 Times in 7 Posts

dang that looks confusing, good work though, your making progress!
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following User Says Thank You to screamo For This Useful Post:
marsman478 (03-27-2008)
  #12  
Old 03-26-2008, 08:59 PM
DoerrFan's Avatar
Moderator
 
Join Date: Jul 2007
Device + Firmware: iPhone 3.0
Operating System: Snow Leopard, Windows 7, and Ubuntu.
Location: Massachusetts
Posts: 2,279
Thanks: 131
Thanked 450 Times in 227 Posts
Send a message via AIM to DoerrFan Send a message via Skype™ to DoerrFan

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!
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
The Following User Says Thank You to DoerrFan For This Useful Post:
marsman478 (03-27-2008)
Reply

  Apple Forums & iPhone Forums, Mods, Hacks, News, Themes, Downloads, and more! | ModMyi.com > 3rd Party Apps For iPhone | iPod Touch > iPhone / iPod Touch SDK | Development Discussion

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Go to Top
ModMyI

All times are GMT -6. The time now is 11:52 PM. Powered by vBulletin® Version 3.8.4
If you need Dedicated Server Hosting, you should check out SingleHop. | Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0 Copyright © 2007-09 by ModMy, LLC. All rights reserved.

iPhone News / iPhone Forums / Apple News / Apple Forums / RSS / Contact Us / / Privacy Statement / Top