2

Adding space to strcat

 1 year ago
source link: https://www.codesd.com/item/adding-space-to-strcat.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Adding space to strcat

advertisements

I have two strings char str1[41] e char str2[41]. If I use strcat function to concatenate them I get an unique string without space instead I would have space between these.

this could be a way:

strcat(strcat(str1, " "),str2)

Does it exist another way?


sprintf(destination, "%s %s", str1, str2);

You'll have to provide a destination. You could use str1 as your destination and it might work correctly, but note the way you're currently doing things could cause you to overrun str1s buffer.

asprintf() will allocate a buffer for you, of the correct (read: safe) length, but you must remember to free() that buffer when you're done with it.

Related Articles

Adding space between the bullet and the text in td

How to add space between bullet point and text in td tag Code in c# forming html: ..... names.Add("<tr><td>"); names.Add("\u2022 " + collection.name); names.Add("</td></tr>"); ..... I tried with \u2022

Display of the new input value (adding spaces)

This seems embarrassing to ask even for a newbie like me, but I have a huge headache with displaying new value in the html input field after adding spaces between numbers in html input. Basically, what I want to achieve is to add spaces between numbe

Difficulty adding spaces around equal signs using regular expressions with Notepad ++

I am currently trying to improve the readability of some of my python scripts by adding spaces around the equal signs. For example, currently an assignment looks like this: foo=4 bar[index]=4 and I want to change it to: foo = 4 bar[index] = 4 I've al

Adding space to complete the table length

I am working with a javascript program that needs to be formatted a certain way. Basically, I need to have each section of information from an array be a set length, for example 12 characters long, and no more than that. The problem I am running into

python adding space after some clusters or characters

I have a text file that looks like the following: AELSLAEM A3LYKM AELSLAEM A3LYKM WRH7MT3 AELLHH WBRKAETHH HHL TSMH7 LY LW SMH7T MN FD9LK HHL TTKRM A3LY B MN FD9LK AHRYD AHNAE AHRYD MN FD9LK MN FD9LK AHH7D9R LY HHL LDYK H7JHZ AENTDH6R QLYLAE SAHNTDH6

Perform equal size strings by adding spaces

I have a list of strings. I want to make all strings of equal length. What I've tried so far is int largestLineLength = 0; for(int i=0;i<list.size();i++){ String s = list.get(i); list.remove(s) list.add(s.trim()); } //get the largest line for (String

Adding space to a specific position in a string of uppercase and lowercase letters

Dear stackoverflow users, Many people encounter situations in which they need to modify strings. I have seen many posts related to string modification. But, I have not come across solutions I am looking for. I believe my post would be useful for some

Adding space between fragments with a layout in Android

I have a FrameLayout defined as the following: <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_v

Adding space to the recycling reserve

I have added an recyclerview and floating action button in an activity where each item of recyclerview has some UI elements.Atlast of its item UI cannot be accessedbecause it is getting covered by floating button how to make space only for last item

Adding space to a string

I am trying to add a space to each space until column = 0. I am not sure how to do this. The problem is the following. If you look at a newspaper you will see that the writing is justified to fit into the columns. Write a program that reads in the wi

Can I prevent returns in my code from adding spaces between form elements?

Possible Duplicate: Ignore whitespace in HTML I am creating a Dutch recipe website. The problem is a visual error that occurs when adding new form fields through Javascript. Where the problem occurs In order to describe all the needed ingredients, I

Online keyboard adding space

I am making a working keyboard without plugins on jsFiddle. I have created the keyboard, now I am adding the spacebar. As you may have guessed, when you click the spacebar, I want it to add a space. I tried this with the following code: if ($('.space

C ++ getline adding spaces

I have been trying to fix this problem for days and I can't get it. Basically my code is supposed to read a .csv file produced by wmic and save it to a struct. I can read the data and it is being stored, but the data has an extra space after each cha

Adding space to select the option as alter

I have taxonomy terms hierarchy and I am using them as a filter in a view. It is showing hierarchy in the selectbox, but child terms appearing with hyphen(-). I have tried to drop hyphen in form alter, and I did, but I couldn't replace it blank space

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK