我再次忘记了如何$_在二维数组的循环中表示数组.
foreach(@TWO_DIM_ARRAY){
my @ARRAY = $_;
}
Run Code Online (Sandbox Code Playgroud)
这是意图,但这不起作用.这样做的正确方法是什么?
#include <stdio.h>
typedef struct pduct {char name[20];
int price;
int stock;} PRODUCT;
void init(PRODUCT * product)
{
printf("What is the name of the product: ");
fgets(product->name, 20, stdin);
printf("DEBUG: Did it get written...: %s", product->name);
printf("What is the current stock of the item: ");
scanf("%d", product->stock);
printf("What is the price of the new item: ");
scanf("%d", product->price);
}
int main()
{
PRODUCT products[5];
init(products);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
现在,我真的有点亏.在运行它时,它会询问产品的名称,将其打印出来,以便我知道它存储了它,然后询问库存量,它将崩溃并返回-1.
我不知道出了什么问题.我试着换出fgets用scanf,只是可以肯定的,但同样的事情发生.我猜我struct的设置错了,但我不知道怎么回事.它char可能是阵列吗?此外,无论我如何安排它,它始终是第二个输入.那么为什么第一个这么好呢?
谢谢你的帮助!
%.8Ffprintf 中的格式说明符有什么作用?
什么F意思?
$string = '20110306';
$pattern = '(\d{6})(\d{2})';
$replacement = '$101';
echo preg_replace($pattern, $replacement, $string);
Run Code Online (Sandbox Code Playgroud)
我希望它回应 20110301
我使用http://gskinner.com/RegExr/来提出搜索和替换模式,也许我在更换找到的模式时遗漏了一些东西.
它给了我以下警告:
消息:preg_replace()[function.preg-replace]:未知修饰符'('
我有一个名为"file1"的文本文件,其中包含以下数据:
apple
appLe
app^e
app\^e
Run Code Online (Sandbox Code Playgroud)
现在给出的命令是:
1.)grep app[\^lL]e file1
2.)grep "app[\^lL]e" file1
3.)grep "app[l\^L]e" file1
4.)grep app[l\^L]e file1
output in 1st case : app^e
output in 2nd case :
apple
appLe
app^e
output in 3rd case :
apple
appLe
app^e
output in 4th case :
apple
appLe
app^e
Run Code Online (Sandbox Code Playgroud)
为什么这样..?
请帮忙..!
我需要做以下选择:
select distinct type as option from pages
Run Code Online (Sandbox Code Playgroud)
但我不断收到错误.你能帮我吗?
期望以下例程在单个链表的开头删除节点,但有时会失败.
void remove_from_front(node *start)
{
delete start;
start = start->link;
print_list(start);
}
Run Code Online (Sandbox Code Playgroud) 127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/ HTTP/1.1" 200 169 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/.treeinfo HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/Fedora HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/Server HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/Client HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/RedHat HTTP/1.1" 404 182 "-" "Python-urllib/2.6"
127.0.0.1 - - [08/Mar/2011:00:26:27 +0530] "HEAD /sk/CentOS HTTP/1.1" …Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的序列:
my $seq = "D\IKLR\LK/Q";
Run Code Online (Sandbox Code Playgroud)
我想要做的是将序列分解为单个字母.
所以我希望得到:
my $var = ['D', '\', 'I', 'K', 'L', 'R', '\', 'L', 'K','/' ,'Q'];
Run Code Online (Sandbox Code Playgroud)
但为什么这样做不会:
my @chars = split(//,$seq);
print Dumper \@chars;
Run Code Online (Sandbox Code Playgroud)
它改为:
my $var = ['D', '\\', 'I', 'K', 'L', 'R', '\\', 'L', 'K', 'Q'];
Run Code Online (Sandbox Code Playgroud)
做正确的方法是什么?
似乎无法解决为什么我在打印内容时从此链接列表结构获取垃圾输出.
我的目标是在列表中添加任何内容,一些字符串,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)