char

pass an array of strings from C# to a C++ dll and back again

会有一股神秘感。 提交于 2021-02-17 16:57:32
问题 I have looked around the googleverse and stack overflow and have seen several similar questions to this but none of the answers I have found have worked for me. I am a new member so I am not allowed to comment on answers in someone else's question to ask for clarification so I have had to resort to asking my own. Ok so I am trying to pass a string array from a C# application to a C++ dll and then grab that information in another C# application. I believe I am passing to C++ properly but I can

scanf is using an uninitialized variable; C [duplicate]

霸气de小男生 提交于 2021-02-17 03:29:51
问题 This question already has answers here : why scanf scans a null value (2 answers) Closed 6 years ago . I'm sure there just a silly mistake here, however, I can't figure it out. This is part of my code: char *moving; scanf("%s", moving); When I compile it with gcc, it says the following: newmatrix.c:38:7: warning: ‘moving’ is used uninitialized in this function [-Wuninitialized] Line 38 is the scanf How do I fix this? Thanks 回答1: Allocate memory for moving before using it. Use malloc() .

C++ exception return type why char*

我的梦境 提交于 2021-02-16 17:57:22
问题 Could someone explain why self-written C++ exception, that inherit from exception return a char * and not a string? class myexception: public exception { virtual const char* what() const throw() { return "My exception happened"; } } myex; Source : http://www.cplusplus.com/doc/tutorial/exceptions/ 回答1: Since std::exception was designed as a base class for all exceptions, the interface is written in such a way that specializations do not require code that may throw. They may use it, but they do

Generate all possible string combinations by replacing the hidden “#” number sign

半城伤御伤魂 提交于 2021-02-16 15:00:07
问题 My task is to generates all possible combinations of that rows without the hidden # square. The input is XOXX#OO#XO and here is the example of what the output should be: XOXXOOOOXO XOXXOOOXXO XOXXXOOOXO XOXXXOOXXO I am only allowed to solve this solution iteratively and I am not sure how to fix this and have been working on this code for a week now.. any help would be much appreciated! Here is my code: import java.lang.Math; public class help { public static void main(String[] args) { String

confusion regarding range of char

回眸只為那壹抹淺笑 提交于 2021-02-11 12:36:01
问题 As we know that the range of char is -128 to 127 . The 2's compliment of -128 and the binary of 128 is same, which is 10000000 So why the range of char is -128 to 127 but not -127 to 128 . Where as in case of int , 128 and -128 both are different. 回答1: In twos-complement notation, whenever the high-order bit is 1, the number is negative. So the biggest positive number is 01111111 = 127 and the smallest negative number is 10000000 = -128 The same thing happens for int , but its range is much

Equality of String characters and usual character don't work / How to get indexes of those chars

旧街凉风 提交于 2021-02-11 12:32:29
问题 I am trying to compare the chars of user String with the 2 chars also got from user, and if one of them is equal to char of that String in particular index, so I need to print that index. import java.util.Scanner; public class TestIndexOf { private static String text; private static char ch1, ch2; public static void main(String[] args) { TestIndexOf test = new TestIndexOf(); test.getInput(); System.out.println(test.getIndex(text, ch1, ch2)); } public static void getInput() { Scanner scan =

Arduino How can I use char instead of String (for better memory usage)

偶尔善良 提交于 2021-02-11 12:29:21
问题 I have read thousand times that String library is not the best solution for code and memory optimization. So I need to use char instead of String. I have several functions that return String where I use it for store in file (sd card) or post it to web as param. So in the following sketch, how can i change it to work with char. I know how to save to sd file or post to webserver. I need only help for change the String to char. #include <ThreeWire.h> #include <RtcDS1302.h> ThreeWire myWire(7,8,6

C# Replace all characters in string with value of character key in dictionary

白昼怎懂夜的黑 提交于 2021-02-08 11:37:03
问题 hi i have this dictionary Dictionary<char, string> keys = new Dictionary<char, string>(); keys.Add("a", "23"); keys.Add("A", "95"); keys.Add("d", "12"); keys.Add("D", "69"); and for example this string string text = "Dad"; i want to encrypt the string with dictionary keys and values! the final encrypted string will be: 692312 anyone can help?! 回答1: I suggest using Linq and string.Concat : // Dictionary<string, string> - actual keys are strings Dictionary<string, string> keys = new Dictionary

C# Replace all characters in string with value of character key in dictionary

六眼飞鱼酱① 提交于 2021-02-08 11:35:09
问题 hi i have this dictionary Dictionary<char, string> keys = new Dictionary<char, string>(); keys.Add("a", "23"); keys.Add("A", "95"); keys.Add("d", "12"); keys.Add("D", "69"); and for example this string string text = "Dad"; i want to encrypt the string with dictionary keys and values! the final encrypted string will be: 692312 anyone can help?! 回答1: I suggest using Linq and string.Concat : // Dictionary<string, string> - actual keys are strings Dictionary<string, string> keys = new Dictionary

Reverse a string without strtok in C

谁说胖子不能爱 提交于 2021-02-08 11:15:23
问题 Working on a program that uses RPN (Reverse Polish Notation). I have a function that reverses all the words of string without using strtok or triggering printf (unlike all the solutions found online and here). The function actually works partially as it prints all the words of a given string except the last one and I need help figuring out what's going on. char *extract(char s[]) { if (s[0] == '\0') return NULL; int i = 0; char *p = NULL; while (s[i] != '\0') { if (s[i] == ' ') p = s + i; i++