我正在编写C程序并收到消息“分段错误(核心已转储)”

时间:2019-02-22 17:05:20

标签: c

该程序将找出不在数组中的最小正数。当我尝试测试我的代码时,它显示消息“分段错误(核心已转储)”。我是程序c的新手,有没有人可以帮助您?

  render() {
    const { hasPermission } = this.state;
    if (hasPermission === null) {
      return <Text />;
    }
    if (hasPermission === false) {
      return <Text>Please Give Permission</Text>;
    }
    return (
      <View style={{ flex: 1, padding: 0, zIndex: 0 }}>
        <Text style={{ zIndex: 2, top: 50, left: 100 }}>overlay1</Text>
        <Camera style={{ width: width, height: height, zIndex: 1 }}>
          <Text style={{ zIndex: 1, top: 50, left: 100 }}>overlay2</Text>
        </Camera>

        <TouchableOpacity
          style={{
            position: "absolute",
            bottom: 10,
            alignItems: "center",
            zIndex: 2
          }}
          onPress={this.takeScreenShot}
        >
          <Text style={{ fontSize: 18, marginBottom: 10, color: "black" }}>
            {""}capture{""}
          </Text>
        </TouchableOpacity>
        <TouchableOpacity
          style={{
            position: "absolute",
            bottom: 20,
            alignItems: "center",
            zIndex: 2
          }}
          onPress={() => CameraRoll.saveToCameraRoll(this.state.imageURI)}
        >
          <Text style={{ fontSize: 18, marginBottom: 10, color: "black" }}>
            {""}save{""}
          </Text>
        </TouchableOpacity>

        <View
          style={{
            zIndex: 2,
            position: "absolute",
            top: 50,
            left: 50,
            width: 100,
            height: 100,
            backgroundColor: "black"
          }}
        />
      </View>
    );
  }
}

1 个答案:

答案 0 :(得分:5)

打印部分:

printf('%d',array[k]);

需要双引号:

printf("%d",array[k]);