All Questions
4,927
questions
1
vote
2
answers
109
views
Why doesn't `char` lose data when an `int` is being assigned to it?
I'm a novice C programmer. I defined two variables int x = 0xffffffff and char y = x, thereafter I printed that using the printf("%x\n", y) function; I was expecting something like ff on the ...
0
votes
1
answer
96
views
Adding elements into a char array
I've been trying to make a function in C that takes a string as the input and then prints out a version of that string that only contains alpha characters.
#include <string.h>
#include <ctype....
3
votes
2
answers
70
views
fwscanf failing to read UTF-8 CSV file correctly in C
This program can only use libraries of the C standard.
I'm trying to read a UTF-8 encoded CSV file in C using fwscanf, but I'm encountering issues with the reading process. The file contains rows with ...
0
votes
0
answers
57
views
Italian Text Frequency Analyzer: Handling Special Characters and Accents
The program works well overall; however, it encounters an issue when it processes accented words. When the program encounters words with accented characters, it stops functioning correctly. The exact ...
0
votes
3
answers
157
views
can you typecast an int into 4 chars using structs?
this is my idea:
int main(){
struct mystruct {
char a;
char b;
char c;
char d;
};
struct mystruct structinstance;
//1094795585 is in binary: 01000001 01000001 01000001 01000001 -to ...
3
votes
3
answers
99
views
How can I make char string array in C have dynamic size?
C language
I'm writing a function that relies later on on generating some text that has to hold the length of essentially: 115 letters minus the length of substring within <> from the original ...
0
votes
1
answer
86
views
why cant i access the location in char pointer array with dereference to int pointer as index
im making a project and i was getting an error out of nowhere supposedly so i went into debug mode and couldn't find the error but the error only occurred in a specific place so i copied the code and ...
0
votes
0
answers
33
views
Shift char* array to left [duplicate]
This is my code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int i, j, k;
int arr_size = 5;
char* data[] = {"1234567", "1234576", "1234756&...
0
votes
1
answer
42
views
logic gates codingame struggles
Im new to C and i really need your help
Detail: https://www.codingame.com/training/easy/logic-gates
All of that works okey (for me), except printf("%c ",output_name[0][i]);
My idea is print ...
1
vote
2
answers
51
views
I am running a conditional loop to iterate through an Array to validate that the user only entered digits. Error when I make the comparison to NULL
As the title says. I am making a program where it takes in command line argument from the user and it encrypts the message. Before the user enters the message, they are required to make an 'encryption'...
-1
votes
1
answer
84
views
Weird behaviour in C when hex value(over 0x7f) is assigned to (signed) char
When a hex value "0x000000a1" is assigned to (signed) char, char is equal to "0xffffffa1".
Can anyone explain this weird behaviour?
void main(){
char testVar = 0x000000a1;
...
-4
votes
2
answers
79
views
Escaped backslash (double backslash) in C counting as two bytes in string [closed]
I'm a relatively inexperienced programmer and I'm running into some confusion about escaped backslashes. I'm using strings containing literal backslashes to represent Windows filepaths (for some ...
2
votes
1
answer
75
views
char * vs unsigned char *
So I was playing around with char* and unsigned char* pointers. And I came across this issue:
Code:
#include <stdio.h>
void func(unsigned int max) {
unsigned int* intptr = &max;
...
1
vote
2
answers
56
views
Value of index randomly changes in dynamic character array during for loop
For one of my assignments in my C book, I have to find a way to treat characters as integers. So, I wrote a program that takes an array of characters that represent integers, add them up, and output ...
0
votes
1
answer
104
views
Why does c delete the null character between two char arrays initialized in sequence?
I am learning c. I have the following code:
char s1[] = {'h', 'e', 'l', 'l', 'o'};
char s2[] = {'w', 'o', 'r', 'l', 'd'};
printf("Original strings:\n\t%s\n\t%s\n", s1, s2);
Whenever I ...