标签: token

错误:在struct中的'='标记之前预期':',',',';','}'或'__attribute__'

使用gcc -Wall -std = c99进行编译时遇到错误:

pokerhand.c:20:17: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
Card *cards = malloc(sizeof(Card)*5);

这是我的错误发生的代码

typedef struct card 
{
    char suit;
    char *face;
} Card;

typedef struct hand 
{
    Card *cards = malloc(sizeof(Card)*5);
    char *result;
} Hand;
Run Code Online (Sandbox Code Playgroud)

在这些结构之前我所拥有的只是标题包括

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
Run Code Online (Sandbox Code Playgroud)

c malloc struct token

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

C中的预处理程序命令是否计为令牌?

我正在阅读关于令牌和计算程序中令牌数量的内容.

以前我在某处读过预处理器命令不算作令牌.但是当我在Geeksforgeeks上阅读有关令牌时,它会在"特殊符号"部分中给出:

预处理器(#):预处理器是一个宏处理器,编译器会在实际编译之前自动转换程序.

所以我很困惑,在一个程序中,如果我们写#define它将是一个令牌吗?

例如:

#include<stdio.h> 
#define max 100 
int main() 
{ 
    printf("max is %d", max); 
    return 0; 
} 
Run Code Online (Sandbox Code Playgroud)

这个例子中有多少个令牌.

c token c-preprocessor

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

从字符串中提取标记

我有一个 html 文件,令牌数量未知。用户稍后会将关键字分配给某些数据。我想确定 html 包含多少令牌。标记可以看起来像:¤SomeID¤ 或 ¤Name¤ 甚至 ¤SomeLongerWord¤。

有人可以给我一个带有正则表达式的完整代码,它会将令牌从字符串中收集到列表中吗?

例子:

string ExtractFromThis = "Hello ¤Name¤, do you speak ¤SomeLanguage¤?"
List<string> IldLikeToHave = Magic(ExtractFromThis); 
//IldLikeToHave should contain {"¤Name¤", "¤SomeLanguage¤"}
Run Code Online (Sandbox Code Playgroud)

谢谢!

html c# regex string token

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

意外的令牌"("JavaScript

我检查了所有的括号,看起来对我来说没问题,这是什么交易?(我在Codecademy上做Javascript课程)[随机文本在这里,因为stackoverflow希望我在文本和代码之间有更好的比例]

function StaffMember(name,discountPercent){
    this.name = name;
    this.discountPercent = discountPercent;
}

var sally = new StaffMember("Sally",5);
var bob = new StaffMember("Bob",10);

// Create yourself again as 'me' with a staff discount of 20%
var me = new StaffMember("Axel", 20);

var cashRegister = {
    total:0,
    lastTransactionAmount: 0,
    add: function(itemCost){
        this.total += (itemCost || 0);
        this.lastTransactionAmount = itemCost;
    },
    scan: function(item,quantity){
        switch (item){
        case "eggs": this.add(0.98 * quantity); break;
        case "milk": this.add(1.23 * quantity); break;
        case "magazine": this.add(4.99 * quantity); break;
        case "chocolate": …
Run Code Online (Sandbox Code Playgroud)

javascript token

-3
推荐指数
1
解决办法
112
查看次数

意外的令牌新,找不到答案

我想输入2个数字,代码将从开始到结束数字计算.我想我错过了什么,请看看这个.

    <!DOCTYPE html>
            <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title>Count</title>
    </head>
    <body>

        1st number : <input type="number" id="start"> <br><br>
        2nd number : <input type="number" id="end"> <br><br>
        <button onclick="new()">Count !</button> <br><br>
        <p id="result"></p>

    <script type="text/javascript">

        function new()
               {
                for (start=0 ; start<=end ; start++)
                {
                    var start document.getElementById("start").value;
                    var end document.getElementById("end").value;
                    document.write(start+"<br>");
                    document.getElementById("result").innerHTML=result;
                }
        }
Run Code Online (Sandbox Code Playgroud)

javascript for-loop token

-3
推荐指数
1
解决办法
371
查看次数

标签 统计

token ×5

c ×2

javascript ×2

c# ×1

c-preprocessor ×1

for-loop ×1

html ×1

malloc ×1

regex ×1

string ×1

struct ×1