Convert Char to String in C

To answer the question without reading too much else into it i would You could use the second line in a loop with what ever other string operations you want to keep using char’s as strings.

C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’

Two errors here: first, you’re trying to declare arrays[63] for storing 64 elements, as you’ve probably confused the size of array (n) with the maximum possible index value (that’s n – 1). So it definitely should be litera[64] and liczba[64]. BTW, you have to change this line too – while (i<=64): otherwise you end up trying to access 65th element. And second, you’re trying … Read more

Using cin to input a single letter into a char

You are not inputting or outputting the characters correctly. char letter[2] is an array of 2 characters, not a single character. You want char letter. Further, you are outputting letter[2], which is the third element of an array that only has two values (indexing in C++ starts from 0; the first element is letter[0] and … Read more

The difference between char * and char[] [duplicate]

The most straightforward answer is: The difference here is that will place Hello world in the read-only parts of the memory and making s a pointer to that, making any writing operation on this memory illegal. While doing: puts the literal string in read-only memory and copies the string to newly allocated memory on the … Read more

char array not assignable

Yes char arrays are not assignable just as all arrays aren’t. You should use strcpy for example and so on. Also, you don’t need to declare char class[30]; the longest string I see in your code is “undefined” so should be ok, 9 characters of “undefined” + 1 null terminating byte ‘\0’. And you should … Read more

Using cin for char array

Here is my code: when I type: 12345 6789 It gives me: 6789 Why I failed to save the 5 words char array ‘inp’ and it showed nothing? The second input looks normal though. However, when I set out[3] or out[5], it seems to work alright? It seem that two char array of [5] then … Read more

tech