Skip to content
Advertisement

Tag: string

Convert char array of C into string of C++

I need to convert char array of C into string c++ but the char array is an element of struct. Code: This is my Structure in C and I want to access name[50] in c++ but for that I have to convert it into string. I have tried strcpy and memcpy. I am using ESL_BOOL status; and it is working

Variable reset after scanf

I wrote the below function : I print the currentPlayer on any level to see what’s going on -> here what I get: Why the current player is 0 after scanf? I didn’t touch it. Answer The buffer location has only room for 2 characters and scanf puts an extra NUL character at end. Therefore you have a stack corruption

I need get a substring in Shell Script

i need help. I need get a substring in the next line the result must be: ttl 128 I hope you can help me! Thanks! Answer Try doing this : NOTE b is a word boundary s is a space + mean at least one or more preceding character -P switch is pcre advanced useful syntax for grep -o switch

ruby Array.inspect vs. Array[element].to_s

I’m working with an array, which we’ll call books, of complex objects, which we’ll call Book. The problem is when I call puts “#{books.inspect}”, ruby outputs a stream of binary (unreadable utf8 characters). However, when I call puts #{books[0].to_str}”, I get a brief, pretty output that describes the book in question. Not sure if it is relevant, but Book is

Advertisement