我正在尝试使用C#在PuTTY中运行Unix命令.我有以下代码.但是代码不起作用.我无法打开PuTTY.
static void Main(string[] args)
{
Process cmd = new Process();
cmd.StartInfo.FileName = @"C:\Windows\System32\cmd";
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.RedirectStandardInput = false;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.Start();
cmd.StartInfo.Arguments = "C:\Users\win7\Desktop\putty.exe -ssh mahi@192.168.37.129 22 -pw mahi";
}
Run Code Online (Sandbox Code Playgroud) 我有以下程序
#include <stdio.h>
#include <stdlib.h>
int main()
{
char text1[30],text2[30];
int diff;
puts("Enter text1:");
fgets(text1,30,stdin);
puts("Enter text2:");
fgets(text2,30,stdin);
diff=strcmp(text1,text2);
printf("Difference between %s and %s is %d",text1,text2,diff);
}
Run Code Online (Sandbox Code Playgroud)
如果我将text1作为inputtext而text2作为differencetext,那么差异应该是5,但是对于不同的输入我得到1,我不知道我哪里出错了.