Tag: 分裂

将行拆分为单词+ C的数组

我试图将一行分成一系列单词,但我仍然坚持如何在C中这样做。我的C技能不是很好,所以我想不出一种方法来“执行”我的想法。 她是我迄今为止所拥有的: int beginIndex = 0; int endIndex = 0; int maxWords = 10; while (1) { while (!isspace(str)) { endIndex++; } char *tmp = (string from ‘str’ from beginIndex to endIndex) arr[wordCnt] = tmp; wordCnt++; beginIndex = endIndex; if (wordCnt = maxWords) { return; } } 在我的方法中,我收到(char * str,char * arr [10]),str是我想要在遇到空格时要拆分的行。 arr是我想要存储单词的数组。 有没有办法将我想要的’chunk’的’chunk’复制到我的tmp变量中? […]

在c中拆分字符串

我试图在C中分割一个字符串(不是在C#,C ++或任何其他类型)。 我尝试使用de strtok函数,但事实certificate这只适用于每个单词之间的限制是单个字符这样的空格,分号…. 我有一个变量,它是一个包含html代码的字符串,如下所示: Index of /davidgoudet Parent Directory https://stackoverflow.com/questions/7746818/split-string-in-c/Horario/ https://stackoverflow.com/questions/7746818/split-string-in-c/Oferta/ https://stackoverflow.com/questions/7746818/split-string-in-c/Registro/ Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at turpialdevelopment.com Port 80 而且我希望在hrefrio,Oferta,Registro之类的href标签之间有一个块,但当我尝试使用strtok(字符串,“href”)时,它给了我一些奇怪的结果,这不是我正在寻找的那个。 有任何想法吗? 谢谢

在C中拆分数组

假设我有一个数组,我想从某些索引范围中删除元素。 如果我提前知道数组的大小,数组中每个元素的大小,以及我想删除的索引范围,有什么方法可以避免复制新数组?

C函数用于分隔字符数组中的字符串

我想创建一个函数来使用C中的分隔符拆分文本。两个参数text和separator将传递给函数,函数应该返回一个array of chars 。 例如,如果字符串是Hello Word of C则分隔符是white space 。 那么函数应该返回, 0. Hello 1. Word 2. of 3. C 作为一组字符。 有什么建议?