问题标签 [strchr]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - PHP STRCHR 等价于 JavaScript
javascript中有没有相当于php的strchr的函数?请帮我。谢谢你。
c - Having trouble parsing "file server commands" in C
The commands will be in the form:
command filename bytes\nfile_contents
I'm having no trouble separating ADD, filename, and the number of bytes, but I am not sure how I can get the remainder of the server command, namely the file contents.
This is how I am parsing each command. Currently to get the file contents I am getting the left most char* that is '\n'. the file_contents char* never changes from NULL.
Any suggestions for how to get the file contents?
c++ - 从 char 指针中减去 char 数组会产生一个 int?
在http://www.cplusplus.com/reference/cstring/strchr/的strchr
参考资料中,提供了这个例子。
为什么从指针中减去char
数组加一会得到一个?(由格式类型表示)如果我删除“ ”,程序将不会执行,直到我更改为.str
char
pch
int
%d
-str
%d
%s
c++ - Strchr 不起作用,或者我需要一个替代方法来检查给定字符串中的任何字符是否是另一个字符的一部分
所以我试图检查一个字符串,看看它是否:
- 有 8 个或更多字符
- 至少有一个大写字母
- 至少有一个小写字母
- 至少具有以下字符之一 .,?!;:_!@#
这是我的代码:
提前致谢!
php - strpos() 在指定单词前后显示 n 个字符
我写了一个简单的搜索引擎,想在结果中显示一些文本,实际上我想在搜索查询之前显示 200 个字符,在搜索查询之后显示 200 个字符。
例子:
搜索查询:测试
结果:
哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇!
我想要这个输出:
... 呜呜呜呜呜测试
前后各有 3 个点。
但我不知道如何将其设置为在 $text 中显示 $term 之前的 200 个字符和 $term 之后的 200 个字符。
c - C中strchr的问题
我无法弄清楚为什么Strchr()
不在我的功能中工作。我需要查看用户猜测是否匹配隐藏单词中的任何字母。这是一个刽子手游戏。
不管猜对还是错,我的else
陈述都被激活了。我的printf
节目s
被赋予了Null
无论字符是否在单词中的价值。
所以我想我的问题在于这部分代码:
我是 C 的新手,所以我确信我只是缺少一些非常基本的东西。我试图尽可能多地搜索网络,但我似乎无法理解我做错了什么。
c - 使用 strchr() 从一个主字符串创建多个字符串
我正在为一个需要我获取请求行并将其分解为后续部分的类的 C 程序工作。这是出于学习目的,所以我可以期待一个相当标准的请求行。
考虑到这个问题,我打算用某种for()
循环遍历请求行中的每个字符,每次遇到 a 时都会创建一个新字符串SP
,但我想知道是否有一种方法可以strchr()
用来指向每个“一块”的请求线?
由于请求行看起来像单个空格method SP request-target SP HTTP-version CRLF
在哪里SP
,有没有什么方法可以创建一个函数strchr(request-line, ' ')
来创建一个string
(或char*
或char[ ]
),然后在下一个结束SP
?
编辑:
所以我可以做类似的事情
但是,“方法”不是之后的每个字符SP
吗?如何“修剪”放入变量中的内容?还是我完全误解了这个功能是如何工作的?
c - strchr 在 C 中不工作
所以现在我正在尝试用 C 编写一个程序,它接受一个字符串并检查正确的标点符号(例如以'.'、'?' 或'!' 结尾)。我正在尝试使用 strchr 函数来测试并查看字符串中的最后一个字符是否是在 for 循环中使用 if 循环的标点符号之一。但是,当我运行程序时,它似乎一起跳过了 if 循环。
这是程序:
我已经尝试了很多不同的方式,例如尝试 strstr ,甚至通过 get 以不同的方式存储它(我通过 gcc 很快了解到,一些研究不是要走的路。)
当我输入一个没有标点符号的句子时,我完全不知道为什么这不起作用。
抱歉,如果这真的很简单,我对此很陌生。
提前致谢。
c++ - How can I read accented characters in C++ and use them with isalnum?
I am programming in French and, because of that, I need to use accented characters. I can output them by using
#include <locale>
and setlocale(LC_ALL, "")
, but there seems to be a problem when I read accented characters. Here is simple example I made to show the problem :
Here is an output example before the program crashes :
I noticed the debugger from Visual Studio shows that I have written something different than what it outputs :
The error shown seems to tell that only characters between -1 and 255 can be used but, according to the ASCII table the value of the accented characters I used in the example above do not exceed this limit.
Here is a picture of the error dialog that pops up : Error message: Expression: c >= -1 && c <= 255
Can someone please tell me what I am doing wrong or give me a solution for this? Thank you in advance. :)
c - 如何使用strchr在c中获取子字符串
我正在尝试获取字符串的一部分。
我有以下代码:
问题是获取第二个单词并将其存储在 word2 中。为此,我尝试使用strchr
来定位空间。但是我第二次使用strchr
我需要一个偏移量来找到第二个空间。我尝试了以下方法:
变量b
和e
应该包含空格字符在mystring
. 最终word2
应该包含。
另一种解决方案是使用循环“遍历”字符串,但这会欺骗函数。quick
strchr