本文介绍了快速添加:执行被中断,原因:EXC_BAD_INSTRUCTION(代码= EXC_l386_INVOP,子代码= 0x0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Swift中将两个数字相加并打印其总和

I'm trying to add two numbers in Swift and print its sum

import Foundation

func solveMefirst(firstNo: Int , secondNo: Int) -> Int {
    return firstNo + secondNo
}

let num1 = readLine()
let num2 = readLine()

var IntNum1 = Int(num1!) ** Execution was interrupted, reason: EXC_BAD_INSTRUCTION (Code=EXC_l386_INVOP, subcode=0x0). **
var IntNum2 = Int(num2!)

let sum = solveMefirst(IntNum1!, secondNo: IntNum2!)
print(sum)

但不幸的是,此错误出现并停止了在操场上的执行.

But unfortunately this error comes out and stops the execution in playground.

Execution was interrupted, reason: EXC_BAD_INSTRUCTION (Code=EXC_l386_INVOP, subcode=0x0).

不明白,这是怎么回事?

Could not understand, what is wrong in this?

更新

还请解释如何在游乐场中运行此命令行程序?

Also please explain how to run this command line program in playground?

如何从运动场中获取输入??

How can I take input from playground??.

推荐答案

我使用命令行运行了它.我认为您正在使用游戏场地,但没有输入num1和num2的输入.运行项目后,输入数字1,然后按Enter.然后输入第二个数字,然后按Enter键.它会给您想要的结果.您的代码运行正常.我在这里运行.

I ran it using command line. I think you are using play ground but you didn't take input for num1 and num2.After running the project take input for number 1 then press enter. Then take input for number two and press enter. It will give you the desired result. Your code is working fine. I run it here.

这篇关于快速添加:执行被中断,原因:EXC_BAD_INSTRUCTION(代码= EXC_l386_INVOP,子代码= 0x0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 01:27