小编PnP*_*PnP的帖子

链接列表创建 - 垃圾输出?

似乎无法解决为什么我在打印内容时从此链接列表结构获取垃圾输出.

我的目标是在列表中添加任何内容,一些字符串,char by char,它应该反向打印出来.我使用额外的头部+尾部结构的原因是我可以打印出反向输入的订单行.

typedef struct List {
 char c;
 struct List *next;
}List;

typedef struct  {
 List *head;
 List *tail;
}FullList;

List* InsertList(int hd, List* t1) {
 List *t = (List*)calloc(1,sizeof(List));
 t->c = hd; 
 t->next = t1;
return t;
}


FullList addToStart(FullList c, char element) {
 if (c.head == NULL) {
    c.head = c.tail = InsertList(element, NULL);
 }else {
    c.head = InsertList(element, c.head);
 }
return c;
}

int main(void) {
 FullList InOrder;
 FullList Reverse;
 InOrder.head = NULL;
 Reverse.head = …
Run Code Online (Sandbox Code Playgroud)

c pointers linked-list data-structures

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

递归设置NTFS权限

所以基本上我们有一个大型共享驱动器,其中包含许多顶级文件夹,每个文件夹包含许多子文件夹和文件.

E:\Share\%Username%
E:\Share\%Username%\Folder1
E:\Share\%Username%\Folder2
E:\Share\%Username%\Folder2\Folder3
Run Code Online (Sandbox Code Playgroud)

在这些文件夹中的每一个都是文件 - 现在基本上随着时间的推移,权限已经变得混乱,我想要做的事情基本上是取得顶级内所有内容的所有权:

E:\Share\%username%\
Run Code Online (Sandbox Code Playgroud)

但也要设置它,以便该文件夹中的任何内容都将从其父文件夹继承权限,所以任何内容:

E:\Share\%Username%\[Whatever is at this level and below] (whether files or folders)
Run Code Online (Sandbox Code Playgroud)

继承自:

E:\Share\%username%\
Run Code Online (Sandbox Code Playgroud)

这可以通过批处理脚本来实现吗?

permissions powershell recursion ntfs batch-file

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

测试连接返回值

所以Test-Connection-quietswitch可以返回一个布尔值.现在我需要以某种方式测试以确定是真还是假,然后执行依赖于该结果的动作.那可能吗?我对Powershell很新,但我假设逻辑如下:

If {Test-Connection -quiet PCNAME} == TRUE then..
Else... 
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

powershell

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

关掉Powershell的回声

我有一个获取共享大小的命令 - 但是由于基于谁自然运行脚本的权限,它会使控制台发生错误.

 $shareSize = [math]::round((Get-ChildItem $($share.path) -Recurse -Force | Measure-Object -Property Length -Sum ).Sum/1GB)
Run Code Online (Sandbox Code Playgroud)

我想抑制错误,如果可能的话将ECHO关闭?

powershell

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

所有Win Forms中均可使用的功能

C#的新手 - 从Powershell和Java中的真正管理员转变.我正在使用MS函数来解密文件:

static void DecryptFile(string sInputFilename, string sOutputFilename, string sKey)
    {
        DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
        //A 64 bit key and IV is required for this provider.
        //Set secret key For DES algorithm.
        DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
        //Set initialization vector.
        DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);

        //Create a file stream to read the encrypted file back.
        FileStream fsread = new FileStream(sInputFilename,
           FileMode.Open,
           FileAccess.Read);
        //Create a DES decryptor from the DES instance.
        ICryptoTransform desdecrypt = DES.CreateDecryptor();
        //Create crypto stream set to read and do …
Run Code Online (Sandbox Code Playgroud)

c#

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

复制文件排除一个文件夹

基本上,我想复制一个文件夹中除一个文件夹之外的所有内容,该文件夹恰好是我的程序存储日志的位置。(我知道我可以将日志存储在其他地方,但我有我的理由)。到目前为止我有:

private void btnCopyFiles_Click(object sender, EventArgs e)
    {
        try
        {
            //Copy all the files
            foreach (string newPath in Directory.GetFiles(@"\\xxx\yyy", "*.*",
                            SearchOption.AllDirectories)
                            .Where(p => p != Logging.fullLoggingPath))
                File.Copy(newPath, newPath.Replace(@"\\xxx\yyy", @"C:\bbb"));
            using (StreamWriter w = File.AppendText(Logging.fullLoggingPath))
            {
                Logging.Log("All necessary files copied to C:\\bbb", w);
            }
        }
        catch
        {
            using (StreamWriter w = File.AppendText(Logging.fullLoggingPath))
            {
                Logging.Log("Error copying files, make sure you have permissions to access the drive and write to the folder.", w);
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

我如何修改它以排除其中的一个特定文件夹\\xxx\yyy

c#

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

关于数组和指针

一个简短的问题主要是在这个例子中理解指针如何与数组一起工作:

char *lineptr[MAXLENGTH]
Run Code Online (Sandbox Code Playgroud)

现在我明白这与char **lineptr数组本身就是一个指针是一样的.

我的问题是它如何以不同的形式/去引用状态工作,例如:

lineptr
*lineptr
**lineptr
*lineptr[]
Run Code Online (Sandbox Code Playgroud)

在每个状态中,发生了什么,每个州在代码中做什么/工作?

任何帮助深表感谢!

c arrays pointers

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

C - 将输出写入文件

EDIT: 

void print(const int *v, const int size) {
 FILE *fpIn;
 fpIn = fopen("char-array.txt", "a");
 int i;  
 if (v != 0) {
   for (i = 0; i < size; i++) {
     printf("%d", (int)v[i]);
     fprintf(fpIn, "%d\n", (int)v[i]);   
   }
   perm_count++;
   printf("\n");
 }
 fclose(fpIn);
} 
Run Code Online (Sandbox Code Playgroud)

我想这是一个相对简单的问题:)

基本上该程序使用置换算法,并将输出打印到控制台中的标准输出.我还想通过fprintf将内容写入文件.虽然我似乎无法让它工作.它只是将垃圾字符打印到文本文件的第一行,仅此而已!

我将粘贴下面的代码,非常感谢帮助!在print函数中可以找到写入文件代码.

谢谢,

T.

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>

#include <time.h>
clock_t startm, stopm;
#define START if ( (startm = clock()) == -1) {printf("Error calling clock");exit(1);}
#define STOP if ( (stopm = …
Run Code Online (Sandbox Code Playgroud)

c io printf fopen fclose

0
推荐指数
1
解决办法
2万
查看次数