All Questions
Tagged with dynamic-arrays string
35 questions
0
votes
0
answers
96
views
How do I turn a dynamic int array into a string
Hi all I am having an issue where I cannot convert a dynamic int array into a string, if you look at the bottom of SumOf2Strings() you can see where I attempted to work out a way where I can just do ...
1
vote
1
answer
50
views
How I can control the length of the string that I want to enter during runtime and then reallocate the memory to store larger string?
For example, I want to enter a string that can store only five elements. It can be "Hello", but if I enter more than 5 elements like "Hello World". It stores only the "Hello&...
0
votes
0
answers
36
views
Problem with reallocating dynamic string array( without using vector ) [duplicate]
int size = 2;
string *s = new string[size];
s[0] = "First";
s[1] = "Second";
//reallocating memory and increasing its size
size++;
s = (string*)realloc(s, size * sizeof(string));/...
0
votes
1
answer
123
views
Is correct this delete operation from a dynamic array? How to fix memory?
I have a dynamic array of strings, for example "123", "231" etc.
Next I need to delete a particular array string. For the deletion I used the normal technique used for static ...
0
votes
2
answers
70
views
C++ segmentation fault using dynamic arrays of strings
My string-dynamic-array.cpp file
#include <iostream>
#include <string>
class DynamicArray
{
public:
DynamicArray()
: mCapacity(1), mNumberOfElements(0)
{
mArray = new ...
0
votes
2
answers
70
views
Find duplicates in first column and take average based on third column
My issue here is I need to compute average time for each Id and compute average time of each id.
Sample data
T1,2020-01-16,11:16pm,start
T2,2020-01-16,11:18pm,start
T1,2020-01-16,11:20pm,end
T2,...
2
votes
1
answer
56
views
Extracting words from a string into dynamic 2D char array
I have a dynamic char array that contains a string. I'm trying to extract all the words from this string into a dynamic 2d char array. Here's my code:
int rows = 1;
char *input_words = malloc((rows)*...
1
vote
1
answer
237
views
c++: segmentation fault (core dumped)
I am trying to make a dynamic array implementation in C++ using pointers and templates so that I can accept all types. The code worked fine with int but using string gives an error. I tried online ...
0
votes
1
answer
55
views
Seg fault when printing string array line, works fine when printed character by character
I have this code:
char **data;
int start = 0;
data = malloc(all_names * sizeof(char*));
fd=open(argv[1],O_RDWR|O_CREAT,S_IRWXU);
for(i=0; i<all_names; i++){
data[i] = ...
1
vote
0
answers
260
views
C++ Access violation writing location when adding strings to a dynamic array
I'm implementing a dynamic array. My default array capacity is 10. When I'm trying to add more than 10 randomized strings I'm getting an error "Access violation writing location. this-> **_Myproxy ** ...
0
votes
1
answer
54
views
Dynamic array of string skips the first index
I am doing a program in which the user inputs the wage, name and the number of working hours per month for a certain number of employees. This piece of code is supposed to recieve Nemp employees and ...
1
vote
1
answer
264
views
C: 2-Dimensional String Array Segmentation Fault
Trying to make a small program that separates words within a big string and stores each word (of the big string) in a string (i.e pointer) in an array of strings (i.e pointers); forming a 2-...
1
vote
1
answer
53
views
Outputting a string pointer array
I'm having a bit of trouble figuring out exactly what I am doing wrong here, and haven't found any posts with the same issue. I am using a dynamic array of strings to hold a binary tree with the root ...
-3
votes
1
answer
901
views
C++ EnumWindows, store the list in a string array
I'm new on C++, I started learning just a couple of weeks ago.
At the moment I'm trying to store the title of all windows with a specific class name in a dynamic string array.
Until now I did it ...
-1
votes
1
answer
577
views
C dynamic array of strings
I'm trying to write a simple implementation of dynamic arrays of strings in C. Here's my code (minus the includes and main function etc ...):
typedef char* string;
typedef struct {
string* list;...