【发布时间】:2020-11-18 12:48:34
【问题描述】:
首先我会说我实际上可以编译 C,至少它确实适用于简单的“hello world”。但是,我无法编译以下 .c 代码:
#include <stdio.h>
#include <stdlib.h>
#define STRINGSIZE 10
int getLastPosition(char word[])
{
int cont=0;
while(cont<STRINGSIZE)
{
if(word[cont]=='\0')
{
break;
}
cont++;
}
return cont;
}
void cipher(int key, char *firstChar, char *lastChar)
{
char *currentChar = NULL;
currentChar = firstChar;
while(currentChar<lastChar)
{
*currentChar += key;
currentChar++;
}
printf("\nThe ciphered word is: ");
currentChar = firstChar;
while(currentChar<lastChar)
{
printf("%c", *currentChar);
currentChar++;
}
}
int main()
{
char word[STRINGSIZE];
char *firstChar = NULL;
char *lastChar = NULL;
int key;
printf("Enter a word to cipher (max 10 chars)> \n");
scanf("%s",word);
printf("Choose a number to cipher the word > \n");
scanf("%d",&key);
firstChar = &word[0];
lastChar = firstChar + getLastPosition(word);
cipher(key, firstChar, lastChar);
}
我没有阻止输出文件的防病毒软件。 但是,我从任务管理器中看到 cipher.exe 确实作为进程加载,但终止任务并重新运行 c 代码对我不起作用。 有人可以帮忙吗?
【问题讨论】:
-
“对我不起作用”到底是什么意思?当你从
cmd运行它时会发生什么? -
您确定您已成功终止进程吗?
-
我用 taskkill /im cipher.exe /f /t 命令从 cmd 杀死了任务
-
如果你在 kill 命令之后得到一个新的进程列表,你能确认它已经消失了吗?
-
@user4581301 是的,它消失了