我无法弄清楚strcpy(I can't figure out strcpy)
这是一个未完成的代码,用于将字母数字字符转换为摩尔斯电码。 到目前为止,只有字符“A”在集合中。 我似乎无法将摩尔代码字符串“a”复制到变量“c”中。 编译器告诉我,传递
strcpy
参数1使得指针来自整数而没有强制转换。#include <stdio.h> #include <ctype.h> #include <string.h> int main(){ char c; /* variable to hold character input by user */ char sentence[ 80 ]; /* create char array */ int i = 0; /* initialize counter i */ const char *a = ".- "; /* prompt user to enter line of text */ puts( "Enter a line of text:" ); /* use getchar to read each character */ while ( ( c = getchar() ) != '\n') { c = toupper(c); switch (c){ case 'A': strcpy(c, a); break } sentence[ i++ ] = c; } /* end while */ sentence[ i ] = '\0'; /* terminate string */ /* use puts to display sentence */ puts( "\nThe line entered was:" ); puts( sentence ); return 0; }
This is an unfinished code for converting alphanumeric characters into Morse code. So far only the character "A" is in set. I can't seem to copy the Morse code string of "a" into the variable "c". The compiler tells me that passing argument 1 of
strcpy
makes pointer from integer without a cast.#include <stdio.h> #include <ctype.h> #include <string.h> int main(){ char c; /* variable to hold character input by user */ char sentence[ 80 ]; /* create char array */ int i = 0; /* initialize counter i */ const char *a = ".- "; /* prompt user to enter line of text */ puts( "Enter a line of text:" ); /* use getchar to read each character */ while ( ( c = getchar() ) != '\n') { c = toupper(c); switch (c){ case 'A': strcpy(c, a); break } sentence[ i++ ] = c; } /* end while */ sentence[ i ] = '\0'; /* terminate string */ /* use puts to display sentence */ puts( "\nThe line entered was:" ); puts( sentence ); return 0; }
原文:https://stackoverflow.com/questions/28075877
最满意答案
字符
−
对于减号运算符不是正确的python标识符,您需要-
而是:>>> 3 − 1 File "<stdin>", line 1 3 − 1 ^ SyntaxError: invalid character in identifier >>> >>> 3 - 1 2
它实际上是一个代码为8722的unicode:
>>> ord('−') 8722
Character
−
is not a correct python identifier for minus operator, you need-
instead:>>> 3 − 1 File "<stdin>", line 1 3 − 1 ^ SyntaxError: invalid character in identifier >>> >>> 3 - 1 2
It's actually a unicode with code point 8722:
>>> ord('−') 8722
相关问答
更多-
在这一行之后: actualCustomer.setAge(scan.nextInt()); 你应该打电话给: scan.nextLine(); 因为在scan.nextInt()之后有一个新的行字符需要读取(在输入int您按Enter确认您的输入并且您错过了从扫描仪读取它)。 而不是写这两行: actualCustomer.setAge(scan.nextInt()); scan.nextLine(); 您可能想要将其更改为: actualCustomer.setAge(Integer.parseI ...
-
我已经发布了一个版本(1.1.0.26),它应该为你解决这个问题,Nuget需要花几分钟来索引它,所以从发布时间开始给它1/2小时左右...... 让我知道! I have published a version (1.1.0.26) which should resolve this for you, it'll take a few mins for Nuget to index it, so give it 1/2 an hour or so from when this is posted... L ...
-
字符−对于减号运算符不是正确的python标识符,您需要-而是: >>> 3 − 1 File "
", line 1 3 − 1 ^ SyntaxError: invalid character in identifier >>> >>> 3 - 1 2 它实际上是一个代码为8722的unicode: >>> ord('−') 8722 Character − is not a correct python identifier for minus operato ... -
编译器没有输出(No output from compiler)[2023-05-25]
你的tsconfig.json包含"noEmit": true,它特别指示编译器不要发出Javascript代码。 Your tsconfig.json contains "noEmit": true, which specifically instructs the compiler not to emit the Javascript code. -
看起来您使用的是过时的版本。 请查看教程的代码并将其与您的代码进行比较,不再需要使用该模板。 只需使用带有.ng.html结尾文件的常规Angular代码 祝你好运! Looks like you are using an outdated version. Please look at the code of the tutorial and compare it to yours, there is no need anymore to use the template. Just use regula ...
-
不合法的识别符?(Invalid Identifier?)[2021-09-16]
正如我从您发布的查询中看到的,您应该有两个JOIN而您只指定一个JOIN ON条件 from "TEST"."DATA_POINT_UPLOAD_DATA" JOIN "TEST"."COMPONENT_UPLOAD_DATA" ONjoin "TEST"."COMPONENT_DATA_POINT" on "DATA_POINT_UPLOAD_DATA"."COMPONENT_DATA_POINT_ID" = "COMPONE ... -
您的程序可以简化如下: # read the file into a list of lines with open('data.csv','r') as f: lines = f.read().split("\n") print("Number of lines is {}".format(len(lines))) word = 'someword' # dummy word. you take it from input # iterate over lines, and print o ...
-
Django中标识符(urls.py,第5行)中的无效字符(invalid character in identifier (urls.py, line 5) in Django)[2022-08-21]
你输的是错误的引号。 更换: r’^home/’ 有: r'^home/' You are putting the wrong quotes. Replace: r’^home/’ with: r'^home/' -
我不明白编译错误(I don't understand the compiler errors)[2024-03-16]
好的,所以这就是你收到错误的原因。 对于第一个和第二个错误,您的*float应该是float * 。 执行*float对编译器没有任何意义,因此会产生错误。 另一方面,执行float *告诉编译器你想要一个指向float的指针,并且完全有效。 对于第三个和第四个错误,您错误地在函数调用中包含了类型。 不要这样做! 它会产生错误。 只需删除类型,使其看起来像AddDetailToAccumulators(totpayrate, p); 并且这将修复您的错误,假设totpayrate和p是指向主函数中定义的浮点 ... -
我的代码基于你的想法,否则这是工作代码: public static boolean isIntegerParseInt(String str) { try { Integer.parseInt(str); return true; } catch (NumberFormatException nfe) {} return false; } public static void main(String []args){ String po ...