小编Bal*_*ick的帖子

从 perl 数组中删除新行

我正在尝试从文本文件中过滤文件名

my $fname= "filenames.txt";
open (FPTR,$fname) || die "Can't Open File: $fname\n";
chomp(my @filenames = <FPTR>);
Run Code Online (Sandbox Code Playgroud)

文件的上下文如下

file1.pl
file2.pl
file3.pl
.
.
.
file100.pl
Run Code Online (Sandbox Code Playgroud)

但是当我打印 @filenames 数组时,它就像

';AR1 = 'file1.pl
';AR2 = 'file2.pl
';AR3 = 'file3.pl
';AR4 = 'file4.pl
.
.
.
.
$VAR100 = 'file100.pl';
Run Code Online (Sandbox Code Playgroud)

即使我添加了 chomp,新行也没有从数组元素中删除。

arrays perl

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

如果我运行这个程序,即使我将输入设为0,它还是计算得到它的值?

#include<stdio.h>
#include<conio.h>
#include<malloc.h>

void main()
{
    struct node
    {
        int data;
        struct node *next;
    };
    struct node *head,*temp;
    int x;
    clrscr();
    head=(struct node *) malloc (sizeof(struct node));
    temp=head;
    while(temp!=NULL)
    {
        scanf("%d",x);
        temp->data=x;
        if(x==0)
        {temp->next=NULL;}
        else
        {temp->next=(struct node *) malloc (sizeof(struct node));}
        temp=temp->next;
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在编写一个简单的链接列表程序的代码...我可以成功运行该程序但是当我按0时程序没有停止..

c

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

标签 统计

arrays ×1

c ×1

perl ×1