C :: Concatenate Strings In Array (2D) - Function Not Working Right?

Sep 6, 2013

I have a function that concatenate the strings in an array(2D)

Ex 1: Sean Connery Micheal King James Wood

Result: SeanConnery MichealKing JamesWood ...

The concatenation function working correctly and displays correctly in the function. But if I make another function to display it, it shows this

Ex 2: SeanConnery Sean MichealKing Micheal JamesWood James..

It adds to first name. Why?

Code:
void Concatenation( char dest[200][13] ) {
// loop through and concatenation the strings
for(int i=0;i<200;i+=2) {
myStrCat(dest[i],dest[i+1]); // mystrcat is equalto strcat()

[Code] .....

View 4 Replies


ADVERTISEMENT

C/C++ :: Bubble Sort Not Working For Array Of Strings?

Apr 9, 2015

I am trying to sort an array of strings but when I pass it through my bubbleSort function, it gives me a segmentation fault. By print checking, I know that there are strings in the array "f" but it doesn't get sorted.

Note: The file I am putting into this program is a text file with 1000 lines

# include <stdio.h>
# include <stdlib.h>
# include <string.h>

[Code].....

View 1 Replies View Related

C/C++ :: Function To Concatenate Two Linked Lists

Mar 6, 2014

The objective of the project is to become familiar with linked lists by writing a series of basic functions that allow us to manipulate a set of linked lists. I've completed all of the functions except for one.

The function I am stuck on is supposed to do the following:

concatenates list1 and list2 to form a new list,
and returns a pointer to this new list;

Note: new list contains copies of all nodes in list1 and list2 */

View 7 Replies View Related

C :: Trying To Concatenate 2 Elements From Array

Oct 19, 2013

Trying to concatenate the 1st and 2nd element from an array of chars. Then this to be used as a hex value.

so for example
specs[0]='f'
specs[1]='4'

concatenate_value=0xf4

View 9 Replies View Related

C :: Concatenate Array Elements More Than Specified Range

Apr 19, 2013

I m concatenating specific range of digits that are same from an array "element" . I have problem with range. As in my case the range is col_elem[ii]=4, but it will continue reading the next element if it is the same. My code is:

Code:

int element[8]={0,1,3,3,3,0,1,2};
col_elem[ii]=4;
for (rr=0; rr<col_elem[ii];rr++){
join_tmp[qq]=rr;
while ((element[ii]== element[ii+1]) ) {

[code]....

View 4 Replies View Related

C :: How To Concatenate Array Index For Same Elements For Specified Range

Apr 22, 2013

Actually i found some mistakes in my post. So here is the modified version. I want to concatenate the indexes of elements of array that has the same value for specific range.In my case the range is 4

Code:

int element[8]={2,2,0,3,3,0,1,2};
col=4;
int rr;
int qq=0;
for (rr=0; rr<col;rr++){
join_tmp[qq]=rr;
while ((element[rr]== element[rr+1]) ) {
join_tmp[qq]= concatenate(rr+1, join_tmp[qq]);
printf("%d
",join_tmp[qq]);
rr++;
}
qq++;
}

Code:

//FUNCTION TO CONCATENATE INTEGER VALUES OF SAME GROUP IN A COLUMN
unsigned concatenate(unsigned x, unsigned y) {
unsigned pow = 10;
while(y >= pow)
pow *= 10;
return x * pow + y;
}

Code: I want input like
10
2
3
Instead i get
10
2
34

how can i fix it so it will only iterate to the specific range?

View 2 Replies View Related

C++ :: Working With Strings / Files And Time-tag Calculation

Dec 27, 2012

I'm trying to calculate a series of times from start to end, and find out the duration between them, sum them up and see if they're above a certain value or not, for each particular instance.

My goal is to provide a prepared text file with time tags such as this:

Mon 19-Nov-2012 09:12 Mon 19-Nov-2012 09:34
Wed 21-Nov-2012 13:14Wed 21-Nov-2012 17:11
Fri 07-Dec-2012 15:21Fri 07-Dec-2012 15:26
=============================================
Mon 26-Nov-2012 12:50Tue 27-Nov-2012 15:29
Wed 12-Dec-2012 13:07Wed 12-Dec-2012 14:58
Fri 14-Dec-2012 14:22Fri 14-Dec-2012 14:29

And the program is able to calculate the total time relevant to each instance (instances separated by a line of '=').

Some form of number should somehow identify each instance or something similar and a text file is generated with total time printed for each instance. E.g.

Instance 1: 00h22m + 03h57m + 00h05m = 04h24m
Instance 2: 04h15m + 07h44m + 01h51m + 00h07m = 14h04m

Now I'm currently working on making the logic to calculate time within the ranges I'd like based on several parameters.

Are there any references I can use when it comes to working with strings in order to seek and extract these values in order to work with them? The documentation available on this website, despite being very informative, does not show practical applications of said class and I'm at a loss on how to implement the functionality.

View 17 Replies View Related

C++ ::  Class Safe Array Type Print Function Not Working When Called

Oct 22, 2013

I've created a function where you can choose any bounds for an array based list (positive or negative, as long as the first position is smaller than the last position). However for some reason when I call the print() function in my application program it doesn't do anything. My print function is technically correct (I still have work to do on the output) but I can't figure out why it wont show anything at all. Below is my header, implementation, and main program files, along with results from running the program.

Header File:

//safearrayType Header File
class safeArrayType {
public:
void print() const;
void insertAt(int location, const int& insertItem);
safeArrayType(int firstPlace=0, int maxPlace = 100);

[Code] ....

ResultsEnter the first bound of yourlist: -3(this was my input)
Enter the last bound of yourlist: 7(this was my input)

Press any key to continue...

View 1 Replies View Related

C :: 2D Array With 108 Strings - Shuffle Function?

Sep 7, 2013

I have a 2D array with 108 strings. How do I shuffle it correctly?

Code:
void Shuffle( char dest[208][13] )
{
// Initialize variables
char temp[13];

// Loop and shuffle(swap array values)

[Code] .....

The program force closes.

View 6 Replies View Related

C++ :: Writing Strings Into Array Index Within A Function?

Apr 11, 2014

I'm trying to make a calendar and I don't know how to cin strings into an array's index inside a function.

This is my current program.

Code:
#include<iostream>
#include<string>
using namespace std;
void viewMonth (string month[], int num);
void dayNote (string month[]);
int main()

[Code].....

View 1 Replies View Related

C/C++ :: Writing Strings Into Array Index Using Function

Apr 11, 2014

I'm trying to make a calendar and I don't know how to cin strings into an array's index inside a function.

This is my current program.

#include<iostream>
#include<string>
using namespace std;

void viewMonth (string month[], int num);
void dayNote (string month[]);

[Code] .....

How do I make void dayNote function work so I can cin a string into the desired array index?

View 3 Replies View Related

C++ :: Concatenate Two Char Arrays Into Single Char Array?

Sep 29, 2014

I am trying to concatenate two words from a file together. ex: "joe" "bob" into "joe bob". I have provided my function(s) below. I am somehow obtaining the terminal readout below. I have initialized my memory (I have to use dynamic, dont suggest fixing that). I have set up my char arrays (I HAVE TO USE CHAR ARRAYS (c-style string) DONT SUGGEST STRINGS) I know this is a weird way to do this, but it is academic. I am currently stuck. My file will read in to my tempfName and templName and will concatenate correctly into my tempName, but I am unable to correctly get into my (*playerPtr).name.

/* this is my terminal readout
joe bob
<- nothing is put into (*playerPtr).name, why not?
joe bob joe bob
seg fault*/
/****************************************************************/
//This is here to show my struct/playerInit

[Code]....

View 2 Replies View Related

C++ :: Concatenate Two 2-dimensional Int Arrays Into One Larger 3-dimensional Array

Jul 31, 2013

How can I concatenate two 2-dimensional int arrays into one larger 3-dimensional array. This question is also valid for the 3-dimensional vectors. I know the command for the one dimensional vector as:

std::vector<int> results;
results.reserve(arr1.size() + arr2.size());
results.insert(results.end(), arr1.begin(), arr1.end());
results.insert(results.end(), arr2.begin(), arr2.end());

and for the one dimensional array as:

int * result = new int[size1 + size2];
copy(arr1, arr1 + size1, result);
copy(arr2, arr2 + size2, result + size1);

But I do not know how to make a 3-dimensional array or vector.

View 3 Replies View Related

C++ :: How To Concatenate String Plus Int

Mar 17, 2014

I want to concatenate string+int so i make like that

Code:
for(int i=0;i<n;i++)
{
name="obstacle"+i;
cout<<name;
}

I get in the window
obstacle
obstacl
obstac
obsta
obst
...
..
o

but i want instruction that allow me to get

obstacle0
obstacle1
obstacle2
...

View 6 Replies View Related

C :: Mod Function Not Working

Nov 27, 2013

Code:
#include <stdio.h>
int main() {
int m,c;

for(c=0;c<100;c++) {
m = c % 10;
printf("%d ",m);
}
return(0);
}

When I run this code in my compiler, I get the first nine or ten numbers, and then after that it just spells out the letters in my name in different sequences over and over.

View 3 Replies View Related

C++ :: How To Concatenate Two Vector Char

Dec 1, 2013

This seamed as a simple thing but i am getting something i did not expect: Example:

Code:
vector<char> StrJoin(SubjSeq.size()+ QuerySeq.size());
cout << StrJoin.size()<<"
"; // size x

StrJoin.insert( StrJoin.begin(), QuerySeq.begin(), QuerySeq.end() );
StrJoin.insert( StrJoin.begin(), SubjSeq.begin(), SubjSeq.end() );

cout << StrJoin.size()<<"
"; // x*2

All structures are vector<char>. when i do the above my characters form Query and Subject are copied in my new vector called StrJoin but the size of that vector is twice the size then it should be.

View 3 Replies View Related

C :: How To Concatenate Two Integers Into One Integer

Oct 15, 2014

How i can concatenate two integers into one integer. I have code that concatenate two integers but if the 2nd integer is zero it won't work. How can i modify it so that it can cater the case of y=0 too.

Code:

int concatenate(int x, int y) {
int pow = 10;
while(y >= pow)
pow *= 10;
return x * pow + y;
}

View 12 Replies View Related

C++ :: Calling Another Function Within A Function Not Working

Feb 20, 2013

I have two functions bool check_key(string cKey, string eKey) and bool check_digit(char digit1, char digit2), and I have declared both of them globally (is this the right terminology?) right after the "using namespace std;" and right before the "int main(){".

In the first one, I called the second one . But it is giving me the error: "no match for call to `(std::string) (int&)' ".

Code:
bool check_key(string cKey, string eKey) {
if(cKey!="" && eKey=="") return false;
if(cKey=="" && eKey=="") return true;
if(cKey=="" && eKey!="") return true;
if(cKey.length()!= eKey.length()) return false;
bool flag=true;

[Code] ....

View 2 Replies View Related

C :: Recursive Function Not Working

Nov 9, 2013

the functions checks if the word is a palindrome like"level" "madam" etc. but with input "dfdfdfdffdfd" my recursive function fails.

Code:

/* main.c - Created on: Nov 9, 2013 - Author: Kaj P. Madsen*/
#define MAX 100
#include <string.h>
#include <stdio.h>
int checkPalindrome(char checkString[MAX]);
int checkRecPalindrome(char checkString[MAX], int strLgt, int a);
}

[code]....

results from "dfdfdfdffdfd" added some print to see that its the variables a and strLgt not functioning properly

Code:

dfdfdfdffdfd.
The word is not a palindrome(iterative)
strLgt: 11 a: 0
a: d strLgt: dstrLgt: 10 a: 1
a: f strLgt: fstrLgt: 9 a: 2
a: d strLgt: dstrLgt: 8 a: 3
a: f strLgt: fstrLgt: 7 a: 4

The word is palindrome (recursive)

View 4 Replies View Related

C :: Rounding Function Not Working

Oct 12, 2013

Why the roundf function is not successfully rounding my numbers.

Code:
#include <stdio.h>
#include <math.h>
//function declarations
void CelToFah (int ctemp, int ftemp);

[Code]....

it produces a correct number when called, but it is not a rounded number, the roundf((float)cel) does nothing. I get the same number with and without it.

View 6 Replies View Related

C++ :: String Function Isn't Working?

Dec 6, 2014

The function Reverse does seem to work. Its supposed to take the words in a sentence and then reverse them. For example: "This is nice" to "Nice is this." When I type "This is nice" I get " niceniceis nice"

#include <iostream>
#include <string>
using namespace std;

[Code]....

View 1 Replies View Related

C++ :: Remove Function Not Working?

Jan 24, 2014

Below is my .h file and the code below that is my function that I'm having troubles with. Its suppose to take in a users topic and see if that topic exists, if it does exist then find the keyword, commentcompare will find where that keyword is and delete the comment. However its not deleting anything and its returning temp is NULL.

class comment //adds a comment
{
public:
comment(char * create_comment);

[Code]...

View 3 Replies View Related

C++ :: Function Call Is Not Working

Oct 15, 2013

i think my function call is not working and i dont know how to fix it. Basically i want it to output my getstudent function and once i get the information i want it to output with the displaystudent.

#include <iostream>
#include <string>
using namespace std;
void displayStudent(Student x) {
cout << x.first << ' ' << x.last << endl;
cout << x.id << endl;

[code]....

View 6 Replies View Related

C++ :: Delete Function Not Working?

Oct 9, 2014

making my delete function work. My program does compile but my delete function doesn't work. I haven't finished my last two functions because I am focusing on the delete but how to Sell a title and print the value of all sold titles would be nice as well.

#include <iostream>
#include <cstdlib>
#include <string>

[Code].....

View 2 Replies View Related

C :: How Macro Works To Concatenate Three Integers

Nov 15, 2014

when i was finding a way to concatenate three integers in C, I came across a snippet like this

Code:

#include<stdio.h>
#define cat(a,b,c) a##b##c
int main()
{
int d;
d=cat(1,2,3);
return 0;
}

How the macro works here? I am unable to understand the function '#' plays in the macro.

View 1 Replies View Related

C/C++ :: Call To Function To Calculate Fx/f Is Not Working

Apr 23, 2014

I am writing a program where f is the frequency and the x has the values as well. Now I am calculating the mean which is summation fx divided by summation f. I have the two functions working correctly but the getmean function is not working. It suppose to divide fx/f . check the code below

#include <iostream>
using namespace std;
const int SIZE=5;
class statisticalOperator{

[Code]....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved