小编Kar*_*sir的帖子

分段错误,scanf

我们有一个赋值,即从文件中获取字符,将给定值向右移动(它在代码中有意义),然后将新值存储在新文件中,但我似乎遇到了分段错误,据我所知,这意味着我正在尝试访问我已分配的内存之外的内存?我是C的新手,我设法调试此代码直到这一点,老实说,我不知道该去哪里.我甚至不太明白这个问题是什么.

#include<stdio.h>
//Get Shift amount
//Get ifilename
//Get ofilename
//open them
//Get characters one at a time from input
//Process and shift by shift amount
int main()
{
    int i;//loop value
    char a[62]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";//Variable with every value
    int sa = 0;//Store Shift value
    char ofile[30];//contain the name of output file
    char ifile[30];//contain name of input file
    char value;//Value to keep the current value in

    printf("How far in ascii values would you like to shift?\n");
    scanf("%i", sa);//Get shift
    printf("What is the name …
Run Code Online (Sandbox Code Playgroud)

c scanf

1
推荐指数
1
解决办法
167
查看次数

标签 统计

c ×1

scanf ×1