小编use*_*491的帖子

C中止陷阱6错误

我有这个代码:

void drawInitialNim(int num1, int num2, int num3)
{
    int board[2][50]; //make an array with 3 columns
    int i; // i, j, k are loop counters
    int j;
    int k;

    for(i=0;i<num1+1;i++)      //fill the array with rocks, or 'O'
        board[0][i] = 'O';     //for example, if num1 is 5, fill the first row with 5 rocks
    for (i=0; i<num2+1; i++)
        board[1][i] = 'O';
    for (i=0; i<num3+1; i++)
        board[2][i] = 'O';

    for (j=0; j<2;j++) {       //print the array
      for (k=0; k<50;k++) {
         printf("%d",board[j][k]); …
Run Code Online (Sandbox Code Playgroud)

c arrays loops abort

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

在c中将字符串复制到剪贴板

首先,我知道有一个同名的问题,但它涉及 c++ 而不是 c。

有没有办法在c中将字符串设置到剪贴板?

如果有人好奇的话,这就是提到的问题,即使它是针对 Windows 的。

我需要它在 c 中,因为我正在用 c 编写一个程序,并且我想将一个字符串复制到剪贴板。

printf("Welcome! Please enter a sentence to begin.\n> ");
fgets(sentence, ARR_MAX, stdin);   
//scan in sentence
int i;
char command[ARR_MAX + 25] = {0};
strncat(command, "echo '",6);
strncat(command, sentence, strlen(sentence));
strncat(command, "' | pbcopy",11);
command[ARR_MAX + 24] = '\0';
i = system(command); // Executes echo 'string' | pbcopy
Run Code Online (Sandbox Code Playgroud)

除了字符串之外,上面的代码还保存了 2 个新行。ARR_MAX 为 300。

c macos clipboard

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

模板文字无法与 Tailwind CSS 一起正常工作

我将十六进制颜色传递到道具中,并尝试用它设置元素的背景。这是我的代码:

 let cardColourRGB: string;
 if (cardColour) {
   cardColourRGB = "[" + cardColour + "]";
   console.log(cardColourRGB);
 } else {
   cardColourRGB = "white/50"
 }
Run Code Online (Sandbox Code Playgroud)

在函数中return

 <div className={`bg-${cardColourRGB}`}></div>
Run Code Online (Sandbox Code Playgroud)

传递某些颜色可以,但其他颜色则不行。例如,传入 #AAA32E 作为 prop 不会设置颜色,但直接设置颜色就可以了:

<div className={`bg-[#AAA32E]`}></div>
Run Code Online (Sandbox Code Playgroud)

为什么会这样呢?

css user-interface reactjs template-literals tailwind-css

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