首页 > 解决方案 > Vs 代码内部错误“架构 arm64 的未定义符号”

问题描述

我只是在 CPP 中的 Mac m1 上运行一个基本程序。这是代码:

#include <stdio.h>
int main({
int i, n, num, pos, arr[10];
printf("\n Enter the number of elements in the array");
scanf("%d", &n);
printf("\n arr[%d] = ", I);
scanf("%d", &arr[i]);}
printf("\n Enter the number to be inserted : ");
scanf("%d", &num);
printf("\n Enter the position at which the number has to be added : ");
scanf("%d", &pos);
for(i=n-1;i>=pos;i--)
arr[i+1] = arr[i];
arr[pos] = num;
n = n+1;
printf("\n The array after insertion of %d is : ",num);
for(i=0;i<n;i++)
printf("\n arr[%d] =%d", i, arr[i]);}

每次运行此代码时,我都会收到此错误:

[Running] cd "/Users/siddhpurohit/Documents/vs code/DSU/" && gcc Exp1.c -o Exp1 && "/Users/siddhpurohit/Documents/vs code/DSU/"Exp1
Undefined symbols for architecture arm64:


"_main", referenced from:
 implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[Done] exited with code=1 in 0.227 seconds

如果您知道如何纠正此错误,请告诉我。我是新手,对编码知之甚少……但我希望学习。

标签: arrayscvisual-studio-code

解决方案


#include<stdio.h>
int main(){
int i,n,num,pos,arr[10];
printf("\n enter the number of elements in the array");
scanf("%d",&n);
printf("\n arr[%d] = ",i);
printf("\n enter the number to be inserted: ");
scanf("%d",&num);
printf("\n enter the position at which the number has to be added :");
scanf("%d",&pos);
for(i=n-1;i>=pos;i--)
arr[i+1]=arr[i];
arr[pos]=num;
n=n+1;
printf("\n the array after insertion of %d is : ",num);
for(i=0;i<n;i++)
printf("\n arr[%d] =%d",i,arr[i]);}

推荐阅读