C:从字符串中删除符号(C: Remove symbols from a string)
我是否知道是否有办法从C中的字符串中删除非字母符号?
例如,我有一个
char array[5][5]
:"hi", "my..", "name", "is,,", "bob!"
期望的输出:
"hi", "my", "name", "is", "bob"
反正有没有删除符号?
May I know if there is any way to remove non-alphabetical symbols from a string in C?
For instance I have an
char array[5][5]
with:"hi", "my..", "name", "is,,", "bob!"
Desired output:
"hi", "my", "name", "is", "bob"
Is there anyway to remove the symbols?
原文:https://stackoverflow.com/questions/11176336
最满意答案
小错误,可能是问题:
这个:
&all_flights_divid[1].flight_number,
应该:
&all_flights_divid[i].flight_number, // ^
编辑:
此外,您读取了
arrival_time_minute
两次,而根本没有读取arrival_time_hour
。 修复它应该没问题。Small mistake, that might be the problem:
this:
&all_flights_divid[1].flight_number,
should be:
&all_flights_divid[i].flight_number, // ^
Edit:
Also, you read
arrival_time_minute
twice, and not readingarrival_time_hour
at all. Fix it and it should be OK.
相关问答
更多-
小错误,可能是问题: 这个: &all_flights_divid[1].flight_number, 应该: &all_flights_divid[i].flight_number, // ^ 编辑: 此外,您读取了arrival_time_minute两次,而根本没有读取arrival_time_hour 。 修复它应该没问题。 Small mistake, that might be the problem: this: &all_flights_divid[1]. ...
-
scanf系列函数不能安全使用,特别是在处理整数时。 你提到的第一个案例特别麻烦。 标准说这个: 如果此对象没有适当的类型,或者如果转换的结果无法在对象中表示 ,则行为是未定义的。 干净利落。 你可能会想到%5d技巧等,但你会发现它们不可靠。 或者也许有人会想到errno。 scanf函数不需要设置errno 。 按照这个有趣的小页面 :他们最终完全抛弃scanf 。 所以回到你的C教授那问问他: C99究竟是如何要求sscanf报告错误的呢? The scanf family of function ca ...
-
使用sscanf检查范围'0','9','。'之间的数字。(Use sscanf to check number between range '0 ' , '9' ,'.' .'+ and '-' signs)[2022-09-21]
如果它只是扩展你的sscanf -approach,那么只需添加-+. -characters,并使用数据类型float或double ,它们可以表示浮点值: int main() { char * string = "xx=3300 rr=3.6 zz=-0.8"; float val; if(sscanf(string, "%*[^-+.0123456789]%f", &val)==1) printf("%f\n", val); else ... -
检测负数(Detecting negative numbers)[2023-07-03]
if ($profitloss < 0) { echo "The profitloss is negative"; } 编辑 :我觉得这对于rep来说太简单了,所以这里有一些您可能会发现有用的东西。 在PHP中,我们可以使用abs()函数找到整数的abs() 。 例如,如果我试图弄清楚两个数字之间的区别,我可以这样做: $turnover = 10000; $overheads = 12500; $difference = abs($turnover-$overheads); echo "The ... -
检测负数(Detecting negative number)[2024-02-23]
很大程度上取决于你想象客户试图通过什么类型的论证。 如果它们传递的是整数,并且这个值足够大以保存要使用的值的范围,那么使用std :: size_t没有实际的好处 - 它不会执行任何操作,并且问题的表现方式因为一个显然很庞大的数字更容易混淆。 但是 - 无论如何,最好使用size_t,因为它有助于记录API的期望。 你显然不能对运行时生成的值进行“> 0”的编译时检查,但至少可以消除来自有意识的巨大数字ala的负面输入 templatevoid f(T t) { if ( ... -
有一个称为“对象检测”的热点,试图做你想要的。 通常,您可以从任何图像甚至视频中检测任何内容(数字,人物,汽车等)。 最先进的技术大致分为两类: 更快 - RCNN ,它首先为您感兴趣的对象提出了许多候选窗口,然后检测这些窗口内的实际内容。 SSD只扫描图像一次并检测物体,与Faster-RCNN相比,速度更快但不可靠。 一个众所周知的实时物体检测方法是YOLO(You Only Look Once),它属于SSD类别,并且在这里有一个非常令人印象深刻的实时演示,为您提供物体检测感。 搜索这些方法的名称,您 ...
-
相当于Qt sscanf(Qt sscanf equivalent)[2024-01-18]
QTextStream提供了标准库流的等价物。 不要忘记,文本流应该在字符串之前销毁。 QString mystring = "67 49 213 59"; QTextStream myteststream(&mystring); int a = 0, b = 0, c = 0, d = 0; myteststream >> a >> b >> c >> d; QTextStream provides the equivalent of the standard library's streams. Do ... -
sscanf没有检测到零(sscanf not detecting zeros)[2023-04-13]
问题不在于扫描,而在于打印。 如果你使用这样的格式 printf("%02d", n); 零将确保有一个你想要的前导零 the problem isn't with the scanning, it's with the printing. if you use a format like this printf("%02d", n); that zero will make sure there is a leading zero like you want -
如果我在这里理解你,你就不再问为什么你的代码不起作用,而是如何让它更快。 这实际上是Project Euler寻找解决问题的有效方法的全部乐趣,因此请小心谨慎,首先考虑自己减少搜索空间。 我建议你让Haskell打印出三个列表pX p3,pX p4,pX p5,看看你是如何寻找一个循环的。 如果你像列表理解一样继续,你将从每个列表的第一个元素开始,1035,1024,1080。我很确定你会在选择1035和1024之后立即停止并且不测试任何值的周期P5,更不用说尝试涉及这两个数字的组合的所有排列。 (我还没有 ...
-
你可以尝试这样的事情。 from BeautifulSoup import BeautifulSoup def getPrintUnicode(soup): body='' if isinstance(soup, unicode): soup = soup.replace(''',"'") soup = soup.replace('"','"') soup = soup.replace(' ',' ') ...