[Solved] How does int a=65; printf(“%c”, a); work in c language in GCC?

The printf function has the following declaration: int printf(const char *format, …); The first argument must be a pointer to a char array, but any additional arguments can be of any type, so it’s not a compiler error if a format specifier mismatches the parameter (although it is undefined behavior). This still works however because … Read more

[Solved] Cannot convert char to char

The error is on this line: key[j]=words[index]; key is a std::string key; Therefore, key[j] is a char. words is a std::vector<std::string> words; Therefore, words[index] is a std::string. You cannot assign a std::string to a char. C++ doesn’t work this way. Your code is equivalent to the following: char a; std::string b; a=b; It is not … Read more

[Solved] I cannot process chars [closed]

Instead of setting a character variable which is discarded, I assume you want to use this character to build a new String. StringBuilder sb = new StringBuilder(); for (char ch : dna.toCharArray()) { switch (ch) { case ‘A’: sb.append(‘T’); break; case ‘T’: sb.append(‘A’); break; case ‘G’: sb.append(‘C’); break; case ‘C’: sb.append(‘G’); break; } } String … Read more

[Solved] c – What is a correct way of defining array? [closed]

The correct way to define and initialize your array is char Lookup[][3] = {“00”, “01”, “02”, “03”, “04”, “05”, “06”, “07”, “08”}; Each element of the array Lookup is itself another array of 3 bytes. Counting with the zero terminator, that’s enough space for strings 2 chars long. The number of elements in the array … Read more