HomeStoreForumsWikiiPhone Native AppsiPhone AppsiPhone Apps modmyifone Downloadsmodmyifone Links






Go Back   ModMyiFone.com - iPhone | iPod Touch forums, news, apps, themes. > 3rd Party Apps For iPhone | iPod Touch > iPhone / iPod Touch SDK | Development Discussion
Register FAQ Members List READ THIS Today's Posts Mark Forums Read

iPhone / iPod Touch SDK | Development Discussion SDK questions. A place for iPhone developers to post code snippets, discuss creating iPhone apps, and any other iPhone developing.


iPhone Optimized MMi | Browser Optimized MMi

Get more out of ModMyiFone by joining our free community. By registering you get privileges to download files from our downloads section and you may also post your questions in our forums! It's fast, free, and easy!

Opportunities at MMi | 1.1.4 Unlock|Jailbreak OS X / Win
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-23-2008, 04:25 PM
DoerrFan's Avatar
Livin the iPhone Life
 
Join Date: Jul 2007
Location: Massachusetts
Posts: 1,356
Thanks: 45
Thanked 229 Times in 153 Posts
Send a message via AIM 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
__________________
Like what i said? Hit the Thanks Button!
1.83GHz MacBook 160GB HDD 1GB RAM
3.06GHz iMac 320GB HDD 2GB RAM

SEARCH BEFORE POSTING
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 (permalink)  
Old 03-23-2008, 11:27 PM
drunix's Avatar
Green Apple
 
Join Date: Oct 2007
Posts: 44
Thanks: 13
Thanked 3 Times in 2 Posts

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.

Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #3 (permalink)  
Old 03-24-2008, 01:17 PM
DoerrFan's Avatar
Livin the iPhone Life
 
Join Date: Jul 2007
Location: Massachusetts
Posts: 1,356
Thanks: 45
Thanked 229 Times in 153 Posts
Send a message via AIM 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;
}
__________________
Like what i said? Hit the Thanks Button!
1.83GHz MacBook 160GB HDD 1GB RAM
3.06GHz iMac 320GB HDD 2GB RAM

SEARCH BEFORE POSTING
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #4 (permalink)  
Old 03-24-2008, 01:57 PM
iPhoneaholic
 
Join Date: Oct 2007
Posts: 329
Thanks: 28
Thanked 97 Times in 62 Posts

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
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #5 (permalink)  
Old 03-24-2008, 02:25 PM
DoerrFan's Avatar
Livin the iPhone Life
 
Join Date: Jul 2007
Location: Massachusetts
Posts: 1,356
Thanks: 45
Thanked 229 Times in 153 Posts
Send a message via AIM 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
__________________
Like what i said? Hit the Thanks Button!
1.83GHz MacBook 160GB HDD 1GB RAM
3.06GHz iMac 320GB HDD 2GB RAM

SEARCH BEFORE POSTING
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #6 (permalink)  
Old 03-24-2008, 10:27 PM
What's Jailbreak?
 
Join Date: Aug 2007
Location: Southfield, MI
Posts: 15
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...
__________________
Check out Media Database for the iPhone!
http://www.djkev.com/apps/iPhone.php
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #7 (permalink)  
Old 03-25-2008, 03:49 AM
heath_rox's Avatar
My iPhone is a Part of Me
 
Join Date: Nov 2007
Device + Firmware: IPhone/4GB,8GB,16GB/1.1.3/4/Unlocked
Operating System: OSX Leopard
Location: Australia
Posts: 606
Thanks: 46
Thanked 81 Times in 67 Posts
Send a message via MSN to heath_rox

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

Iphone-1.1.3-04.03.13g-everything working-telstra
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #8 (permalink)  
Old 03-25-2008, 07:23 PM
DoerrFan's Avatar
Livin the iPhone Life
 
Join Date: Jul 2007
Location: Massachusetts
Posts: 1,356
Thanks: 45
Thanked 229 Times in 153 Posts
Send a message via AIM 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.
__________________
Like what i said? Hit the Thanks Button!
1.83GHz MacBook 160GB HDD 1GB RAM
3.06GHz iMac 320GB HDD 2GB RAM

SEARCH BEFORE POSTING
Digg StumbleUpon Delicious Reddit Newsvine Google Yahoo Thanks Reply With Quote
  #9 (permalink)  
Old 03-26-2008, 04:55 PM
My iPhone is a Part of Me
 
Join Date: Jul 2007
Device + Firmware: iPhone 1.1.4
Operating System: XP
Posts: 516
Thanks: 10
Thanked 15 Times in 15 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 (permalink)  
Old 03-26-2008, 05:08 PM
NetMage's Avatar
Developer
 
Join Date: Aug 2007
Device + Firmware: iPhone 1.1.3
Operating System: Windows XP
Location: Virginia
Posts: 981
Thanks: 26
Thanked 161 Times in 134 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.)
__________________
Starlight Computer Wizardry
Pocket-sized Development
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 (permalink)  
Old 03-26-2008, 06: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: 114
Thanks: 11
Thanked 9 Times in 7 Posts

dang that looks confusing, good work though, your making progress!
__________________
Please don't stop the music
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 (permalink)  
Old 03-26-2008, 07:59 PM
DoerrFan's Avatar
Livin the iPhone Life
 
Join Date: Jul 2007
Location: Massachusetts
Posts: 1,356
Thanks: 45
Thanked 229 Times in 153 Posts
Send a message via AIM 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!
__________________
Like what i said? Hit the Thanks Button!
1.83GHz MacBook 160GB HDD 1GB RAM
3.06GHz iMac 320GB HDD 2GB RAM

SEARCH BEFORE POSTING
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

  ModMyiFone.com - iPhone | iPod Touch forums, news, apps, themes. > 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

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

ModMyMoto.com - ModMyGPhone.com - ModMyiFone.com - Managed Dedicated Servers by SingleHop - iPhone Wallpapers - Contact Us - Link to us - Archive - Privacy Statement - - Top
Copyright © 2007-08 by ModMy, LLC. All rights reserved. You may not copy anything on this site unless you link to the original.
All times are GMT -6. The time now is 12:41 PM. Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5
ModMyiFone.com is an independent publication and has not been authorized, sponsored, or otherwise approved by Apple, Inc or Cisco Systems, Inc. The information contained on this site is for educational purposes only.
Forum skin by poetic_folly