All Questions
Tagged with c-strings segmentation-fault
58 questions
0
votes
0
answers
8
views
CString formatting from hexadecimal array causing segmentation fault on Raspberry Pi
Trying to convert a hexadecimal unsigned char array into a CString and printing:
unsigned char hexArray[] = { 0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F };
CString strArray;
strArray.Format(_T("%02x-02x-...
1
vote
4
answers
151
views
C pointer concept segmentation fault
Please take a look of snippet: I am not able to understand why code is giving segmentation fault and garbage characters.
#include <stdio.h>
int main()
{
char *str[1];
str[0] = "...
0
votes
3
answers
161
views
Malloc is not allocating enough memory, despite being hardcoded to allocate exactly two characters
I have a function that, given a pointer to a char array string (Passed by reference), a char character (passed by value), and an unsigned short int length (passed by reference), is supposed to, if ...
0
votes
2
answers
53
views
segmentation fault when accessing pointer element
I have been attempting to parse a string into separate tokens for a command line interface for a project of mine, I have created this function to do it:
char **string_parser(char *input) {
char **...
0
votes
1
answer
191
views
C - How to split a string with delimiter when sometimes there are no values between delimiter?
I am trying to split a string as follows:
1.97E+13,1965.10.30,12:47:01 AM,39.1,23,greece,,,,,10,4.8,4.6,4.6,4.8,4.6,4.7
I am using strtok and giving , as a delimiter but since there are no values ...
1
vote
2
answers
89
views
Debugger gives a segmentation error for strlen
In the code below the debugger shows no error but when I run this piece of code inside a function scope char *s is also in the function scope the debugger gives a segmentation error for the strlen ...
-1
votes
2
answers
122
views
Why am I getting a segmentation fault? C, basic code
Why I am getting a segmentation fault? Unlike other similar questions posted here, it doesn't seem to me that I'm trying to access an array index that is out of memory.
What I want the squeeze(char s1[...
1
vote
3
answers
675
views
What's causing a segmentation fault in my code and what I should do to fix it?
I've been getting segmentation fault and I don't know why. I have a feeling that it's caused by the code under if(isPalindrome(str_array[i]) == 0) but I don't know which one and what to do about it.
P....
-1
votes
3
answers
82
views
How can I return String to the main function?
The goal is actually substituting characters in a string of plaintext to ciphertext. User input the key using the command line argument with the key input of 26 letters.
I encountered problem when I ...
0
votes
1
answer
111
views
Does Segmentation fault occurs due to accessing of large amount of memory
Insertion of large amount of random strings in Red black tree is giving segmentation fault in Ubuntu but the code work fine for insertion of few string(less than 50) . The code though works when it is ...
1
vote
1
answer
142
views
fclose() ends with "Segmentation fault (core dumped)"
I didn't find the answer on internet if there is please link it...
#include <stdio.h>
int main(){
FILE*fp;
char arr[4];
printf("Opening...\n");
fp=fopen("slide....
2
votes
1
answer
84
views
Calloc causes segmantation fault
I am trying to add a set a string in my struct array's struct. I coded this in Macos using gcc (not clang) and works fine but when i import my code to Windows this calloc causes segmantation fault.
...
0
votes
1
answer
301
views
Segmentation fault with strcat and malloc in C
I'm still pretty new to programming, but I'm trying to write a function that duplicates letters in a given string. It takes a series of integer inputs for how many of each letter to include, then ...
0
votes
1
answer
80
views
Allocating array of strings
Today i was having trouble allocating an array of arrays of char (an array of strings), i wrote this function to do so, but when printing the array, i had some problems with memory ( e.g. Segmentation ...
0
votes
0
answers
65
views
Segmentation fault printing c-style string in for-loop
I encountered a segmentation fault when trying to print an element of an array of c-style strings (at the final iteration i=3). However, I am able to print the same element outside the for-loop.
char* ...