532 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
2
votes
2
answers
96
views
Why does my C program segfault when I use strcat with dynamically allocated char arrays? [duplicate]
I need some help understanding the difference in behavior with strcat when passing in dynamically allocated char arrays versus char arrays declared with the index operator.
The following generates a ...
0
votes
1
answer
114
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....
1
vote
1
answer
97
views
Combined usage of getline, strcat and realloc functions
Good afternoon everyone! I wrote my implementation of the cat utility in C and ran into some problems. Here's my code:
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#...
0
votes
0
answers
29
views
Appending individual text file chars to string in C via strcat() [duplicate]
I am trying to read in a text file char by char and append each char to a string.
This code here outputs what I expect, showing each individual char:
char currentStr[MAX_WORD_LEN] = "&...
-3
votes
1
answer
109
views
passing argument 1 of 'strcat' makes pointer from integer without a cast [-Wint-conversion]
I am trying to get 10 random numbers and collect them in a char array to get a random customer ID
But it's giving this warning. I couldn't fix it whatever I do. Can you help?
char customerid(){
...
7
votes
2
answers
215
views
Why some character can't be edited in C++?
I'm trying to write my own strcat function in C++, but it has some problems.
My input is two chars c and a, and my function will return a char pointer to a char which c is concatenated with a.
For ...
2
votes
2
answers
172
views
Why does referencing this char array cause Stack smashing, using C?
The program takes a pointer to a char array and an int. The char array consists of two numbers, separated by a space.
The use of the function is to read the values of the char array as integers and ...
1
vote
2
answers
235
views
doing the no-vowels cs50 problem and ran into an error with strcat
When running my program:
#include <cs50.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
string word = get_string("Give me a word: " );
int j = strlen(...
0
votes
1
answer
36
views
How to load 3 values from a file into a char* array (C)?
I tried implementing a Function which opens a obj file and loops over every character in one line starting from the second character, because the first and the second character are just "v " ...
0
votes
2
answers
68
views
My string variable lost its memory after a block of code
I'm trying to make a simple memory for username and phone number so the user could refer back to it at the end of the big chunk of code, but the string stored in name1 seems to be lost when printing ...
1
vote
2
answers
239
views
trouble using strcat() to concatenate command line arguments
I am trying to write a program for executing multiple programs from command line arguments. I start with concatenating the argv[x] strings I pass through calling the program into bigger strings that ...
0
votes
0
answers
210
views
How to concatenate strings in inline assembly
Im trying to concatenate two given strings using inline assembly in C using the gcc compiler and intel syntax. I have been successfull to print the first string but not the second and I can't figure ...
0
votes
5
answers
170
views
Pointer version of strcat
#include <stdio.h>
void strpcat(char *s, char *t) {
int i = 0;
while (*s++ != '0円')
i++;
while ((*(s+i) = *t++) != '0円')
i++;
}
int main(void) {
char a[20] = &...
0
votes
1
answer
59
views
problem to use srtcat() to add string to string
~~ z_goggamal-input.txt ~~
Make me a sandwich.
What? Make it yourself.
Sudo make me a sandwich.
Okay.
this is the original text file. i need to change this file
~~like this ~~
Make me a sosandwich.
...
1
vote
2
answers
87
views
Segfault when allocating memory to a struct
I want to concatenate using strcat each new tag stored in a struct with char member in a the char tags_cell_concat. I get a segfault
First attempt
#include <stdio.h>
#include <string.h>
#...