Created
August 31, 2014 20:02
-
-
Save neojou/f32f4eb65846389ee9f5 to your computer and use it in GitHub Desktop.
swift input : like scanf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func input() -> String { | |
var keyboard = NSFileHandle.fileHandleWithStandardInput() | |
var inputData = keyboard.availableData | |
return NSString(data: inputData, encoding:NSUTF8StringEncoding) | |
} | |
var inputStr : String; | |
print("Input:"); | |
inputStr = input(); | |
println("You type:" + inputStr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment