עבור לתוכן

בעיות בשימוש ב-scanf עם xcode4.2

Featured Replies

פורסם

אני מריץ את ה-xcode עם vmworkstation אם זה משנה (לא נראה לי שקשור).

כתבתי את הקוד הבא:


#import <Foundation/Foundation.h>
int main (int argc, char *argv[]){
@autoreleasepool {
int age=0;
NSLog(@"Please enter your age:\n");
scanf("%i",&age);

switch (age){
case 1:
NSLog(@"Great age is 1 !!");
break;
case 2:
NSLog(@"Great age is 2 !!");
break;
case 3:
NSLog(@"Great age is 3 !!");
break;
case 4:
NSLog(@"Great age is 4 !!");
break;
default:
NSLog(@"This also a great age");
break;
}

}

}

הבעיה היא שכשאני מריץ , אני מקבל עבור ערכים שונים את זה:


GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
sharedlibrary apply-load-rules all
[Switching to process 332 thread 0x0]
2012-03-10 14:22:42.863 frst[332:707] Please enter your age:
(gdb) 1
Undefined command: "1". Try "help".
(gdb) 2
Undefined command: "2". Try "help".
(gdb) 3
Undefined command: "3". Try "help".
(gdb) 4
Undefined command: "4". Try "help".
(gdb) 5
Undefined command: "5". Try "help".
(gdb) 6
Undefined command: "6". Try "help".
(gdb) 10
Undefined command: "10". Try "help".
(gdb) 30
Undefined command: "30". Try "help".
(gdb)

אשמח אם אוכל לקבל פתרון לתעלומה... :-\

תודה !!

פורסם
  • מחבר

לא יודע אם צריך stdio.h ב-objective-c...

בעיקרון עשיתי ל-Foundation.h כי נראה לי שזה מקביל ל-stdio.h של c/c++ לא ?

עריכה:

עשיתי import ל-stdio.h עכשיו, וזה לא משפיע לא לטובה ולא לרעה... :nixweiss:

פורסם
  • מחבר

מקפיץ :jump:

יש למישהו רעיון... ? :s05:

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים