strchr

Segmentation fault with g_object_set / strchr

◇◆丶佛笑我妖孽 提交于 2019-12-12 02:12:27
问题 This line get me a segmentation fault : g_object_set(G_OBJECT(data.udpsrc), "port", 5000, "caps", caps, NULL); where data.udpsrc = gst_element_factory_make("udpsrc", "source"); caps = gst_caps_new_empty_simple("application/x-rtp"); Here's the output with gdb : Program received signal SIGSEGV, Segmentation fault. strchr () at ../ports/sysdeps/arm/armv6/strchr.S:28 28 ../ports/sysdeps/arm/armv6/strchr.S: No such file or directory. (gdb) bt #0 strchr () at ../ports/sysdeps/arm/armv6/strchr.S:28

trying to extract complex numbers from strings

牧云@^-^@ 提交于 2019-12-11 16:39:25
问题 I am attempting to extract two columns of numbers from a text file. first column is the real part of the number and the second in the imaginary part. I managed to extract the list of numbers from the file as strings but I don't know how to separate the strings into two parts. I have attempted to use the sscanf function but just hasnt worked. The difficult part is the numbers can be both positive and negative therefore I cant use + and - in the delimiter of the strtok function since it will

strchr函数的应用

孤街醉人 提交于 2019-12-11 15:39:22
strchr 函数接收两个参数,第一个是原来的字符串,第二个是用于标明分割的第一个字符 必须是第一个 。函数将返回一个字符串,是以第二个字符串打头的分割字符串。 # include <iostream> # include <cstring> using namespace std ; int main ( ) { char c [ ] = "I love you!" ; //不能是string类型,必须是char*类型 char key = 'e' ; char * point ; point = strchr ( c , key ) ; //函数有两个参数 printf ( "%s中%c后面的句子是%s" , c , key , point ) ; //point也是字符串类型 } //output I love you ! 中e后面的句子是e you ! 来源: CSDN 作者: 戎码关山 链接: https://blog.csdn.net/dghcs18/article/details/103492368

C function strchr - How to calculate the position of the character?

烂漫一生 提交于 2019-12-11 03:07:40
问题 I have this example code for the strchr function in C. /* strchr example */ #include <stdio.h> #include <string.h> int main () { char str[] = "This is a sample string"; char * pch; printf ("Looking for the 's' character in \"%s\"...\n",str); pch=strchr(str,'s'); while (pch!=NULL) { printf ("found at %d\n",pch-str+1); pch=strchr(pch+1,'s'); } return 0; } The problem is, I don't understand, how this program calculates the position of the looking character. I think it has something to do with

Efficient memcspn

二次信任 提交于 2019-12-11 02:31:09
问题 Does anyone know of an efficient implementation of a memcspn function?? It should behave like strcspn but look for the span in a memory buffer and not in a null terminated string. The target compiler is visualC++ . Thanks, Luca 回答1: One near-optimal implementation: size_t memcspan(const unsigned char *buf, size_t len, const unsigned char *set, size_t n) { size_t i; char set2[1<<CHAR_BIT] = {0}; while (n--) set2[set[n]] = 1; for (i=0; i<len && !set2[buf[i]]; i++); return i; } It might be

Minimally invasive change for strchr on unsigned char * in C++ from a C codebase?

荒凉一梦 提交于 2019-12-11 01:53:51
问题 I'm trying to compile a C codebase as C++, tweaking some of the includes. It uses strchr() on unsigned char pointers, e.g.: #include <string.h> #include <stdio.h> // Cannot modify this file with any non-C-isms, but let's say an include can // be changed (although all things being equal I'd rather not) #include <SomethingICanChange.h> int main(int argc, char* argv[]) { unsigned char b = 'B'; unsigned char const * str = "ABC"; unsigned char const * pos = strchr(str, b); if (pos) { printf(

C 简陋版string操作strcpy strcmp strcat strchr strstr

空扰寡人 提交于 2019-12-09 11:39:02
文件下载地址: http://pan.baidu.com/s/1bn2BcTL 代码如下: #include <stdio.h> #include <stdlib.h> char *strcpy_(char *dest,const char *src); char *strcat_(char *dest,const char *src); int strcmp_(const char *dest,const char *src); int strlen_(const char *src); char *strchr_(char *s, int c); char *strstr_(const char *s,const char *c); int main() { char p[]="xxdexxx"; char q[]="de"; printf("p=%s\n",p); printf("q=%s\n",q); printf("strlen_(p)=%d\n",strlen_(p)); printf("strcpy_(p,q)=%s\n", strcpy_(p,q)); char p1[]="xxdexxx"; char q1[]="de"; printf("strchr_(p,'d')=%s\n",strchr_(p1,'d')); char p2[]="xxdexxx";

strchr()

给你一囗甜甜゛ 提交于 2019-12-06 12:57:22
描述 C 库函数 char *strchr(const char *str, int c) 在参数 str 所指向的字符串中搜索第一次出现字符 c (一个无符号字符)的位置。该函数返回在字符串 str 中第一次出现字符 c 的位置,如果未找到该字符则返回 NULL。 实例 #include <stdio.h> #include <string.h> int main () { const char str[] = "http://www.runoob.com"; const char ch = '.'; char *ret; ret = strchr(str, ch); printf("|%c| 之后的字符串是 - |%s|\n", ch, ret); return(0); } 来源: https://www.cnblogs.com/xumaomao/p/11985594.html

How to convert a char* pointer into a C++ string?

北战南征 提交于 2019-12-04 10:36:50
问题 I have a C++ string . I need to pass this string to a function accepting a char* parameter (for example - strchr() ). a) How do I get that pointer? b) Is there some function equivalent to strschr() that works for C++ strings ? 回答1: To get the C string equivalent of the C++ string object use c_str function. To locate the first occurence of a char in a string object use find_first_of function. Example: string s = "abc"; // call to strlen expects char * cout<<strlen(s.c_str()); // prints 3 // on

How to convert a char* pointer into a C++ string?

百般思念 提交于 2019-12-03 06:14:34
I have a C++ string . I need to pass this string to a function accepting a char* parameter (for example - strchr() ). a) How do I get that pointer? b) Is there some function equivalent to strschr() that works for C++ strings ? To get the C string equivalent of the C++ string object use c_str function. To locate the first occurence of a char in a string object use find_first_of function. Example: string s = "abc"; // call to strlen expects char * cout<<strlen(s.c_str()); // prints 3 // on failure find_first_of return string::npos if(s.find_first_of('a') != string::npos) cout<<s<<" has an a"<