Sponsored Content
Top Forums Programming Concatenate integer and space/newline for cout in C++ Post 303011923 by yifangt on Thursday 25th of January 2018 03:54:04 PM
Old 01-25-2018
Thanks!
I'm surprised the problem seems to be with the higher precedence of the operator "<<" in this case
Code:
cout  << tmp_int << ((j+1)%20) ? "\t":"\n";

which needs to be bracketed as
Code:
cout  << tmp_int << (((j+1)%20) ? "\t":"\n");

Did I miss anything?
 

10 More Discussions You Might Find Interesting

1. Solaris

Dvd files concatenate error: Not enough space

Hi, I downloaded the latest sparc ver of sol10, tried to concatenate the files and encounter error: Not enough space on the disk. Tried from both sol10 x86 and winxp. command used: UNIX: cat file1 file2 file3 file4 file5 > file.iso DOS: copy /b file1 + file2 + file3 + file4 + file5 file.iso... (3 Replies)
Discussion started by: maag
3 Replies

2. UNIX for Advanced & Expert Users

newline character, space and tab after a string

no problem (6 Replies)
Discussion started by: angelina
6 Replies

3. Shell Programming and Scripting

Concatenate the string with the newline character

Hi , i want to Concatenate a string and use the following code str="i" str="$str am \n" str="$str a \n" str="$str boy \n" echo $str I want to ouput this i am a boy However it outputs i am \n a \n boy \n (3 Replies)
Discussion started by: youareapkman
3 Replies

4. Shell Programming and Scripting

Awk adding a space between integer and the rest of the field

Hi, I have a problem where some of the records I need to process have the first address field as something like "10Walpole Street" where obviously I want it to be "10 Walpole Street". I know I need to somehow separate out the integer and probably form a new string variable, but I just don't... (5 Replies)
Discussion started by: jonathanm
5 Replies

5. Shell Programming and Scripting

Using sed I want to replace space by newline

Input: -------------------------- 123asd 456sdasda 789a ------------------------- output wanted: --------------------- 123asd 456sdasda 789a ---------------------- I want this by sed in simple way please help (I know by: tr ' ' '\n' < inputfile )I want it by sed only (5 Replies)
Discussion started by: RahulJoshi
5 Replies

6. UNIX for Dummies Questions & Answers

Remove newline & space

Can someone help me on this. I have a file that has a long line just like below. The long line keeps on being truncated to the next line (new line + space) for some reason. Basically, I just need to remove this problem. Hope somebody can help! Thanks! INPUT FILE: structuralObjectClass:... (4 Replies)
Discussion started by: Orbix
4 Replies

7. Shell Programming and Scripting

concatenate is ignoring space

Hi All,I am facing the below problem I have set a variable: a=`cat a.txt| grep "mad" | cut -c 30-50`the output is coming echo $a1 10 Mad300 3215however the actual ouput is 1.10 Mad300 3215There are 4spaces between 300 and 3215 so if i do: echo "$a" I am getting correct output: 1.10... (3 Replies)
Discussion started by: mad_man12
3 Replies

8. Shell Programming and Scripting

Newline to space code removes 0 from the first line

I am having a peculiar problem. First I run the code below to append 0 at the start of each line in some hundreds of files that I have in a directory. These files have each word in a newline. for f in *.dat; do echo "0" > tmpfile cat $f >> tmpfile mv tmpfile $f done Then I run this... (7 Replies)
Discussion started by: shoaibjameel123
7 Replies

9. Shell Programming and Scripting

Replace 3rd occurance of SPACE with newline

I have file with SQL output as 0001 firstname1 lastname1 0002 firstname2 lastname2 0003 firstname3 lastname3 0004 firstname4 lastname4 Expected output : 0001 firstname1 lastname1 0002 firstname2 lastname2 0003 firstname3 lastname3 0004 firstname4 lastname4 Let me know if this can... (9 Replies)
Discussion started by: sameermohite
9 Replies

10. Shell Programming and Scripting

Replace space by newline error

Hello I have had a requirement where I need to move data to a new line based on a text .So basically as soon as it encounters :61: it should move to a new line Source Data : :61:D100,74NCH1 :61:D797,50NCH2 :61:D89,38NCHK2 :61:D99,38NCHK12 :61:D79,38NCHK22 :61:D29,38NCHK5 Target Data... (11 Replies)
Discussion started by: kamijia83
11 Replies
NUMRANGE(1)						User Contributed Perl Documentation					       NUMRANGE(1)

NAME
numrange - Print out a range of numbers for use in for loops and such. SYNOPSIS
numrange [-dhV] /<expression>/ DESCRIPTION
numrange will print out a list of numbers based on an expression that you specify. This is useful for making a list of numbers for use in for loops and so on. Ranges are inclusive. Ranges of numbers are specified using the .. operator, like this /20..50/, which means all integers from 20 to 50 inclusive. More complex expressions can be generated using the commas and the 'i' increment operator. OPTIONS
-e <set> Exclude the <set> of numbers from the range output. <set> is a set of numbers separated by commas. -n <n> Use <n> as the separator between numbers. By default, it will use a space. Use ' ' or \n for a newline character or use the -N option. -N Just a quick option for using a newline as the separator. -h Help: You're looking at it. -V Increase verbosity. -d Debug mode. For developers EXAMPLES
All numbers from 1 to 10. $ numrange /1..10/ 1 2 3 4 5 6 7 8 9 10 From 10 to 1. Counting down. $ numrange /10..1/ 10 9 8 7 6 5 4 3 2 1 From 1 to 10 and from 15 to 20. $ numrange /1..10,15..20/ 1 2 3 4 5 6 7 8 9 10 15 16 17 18 19 20 Even numbers from 0 to 10 $ numrange /0..10i2/ 0 2 4 6 8 10 Odd numbers. Notice the starting number in the range expression. $ numrange /1..10i2/ 1 3 5 7 9 Factors of 3 between 99 and 120. $ numrange /99..120i3/ 99 102 105 108 111 114 117 120 Decimal numbers $ numrange /1.1..2.5i0.1/ 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1 2.2 2.3 2.4 2.5 And negative numbers too. $ numrange /1.0..-2.0i0.3/ 1 0.7 0.4 0.1 -0.2 -0.5 -0.8 -1.1 -1.4 -1.7 -2 You can also pad numbers when you are counting up. This is a trick of how the Perl programming language deals with ranges: $ numrange /01..15/ 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 BUGS
Even though you can do zero padding on simple ranges, like 001..100, it will not pad zeros on complex ranges like 001..100i2, or for counting downwards. SEE ALSO
seq(1), numaverage(1), numbound(1), numinterval(1), numnormalize(1), numgrep(1), numprocess(1), numsum(1), numrandom(1), numround(1) COPYRIGHT
numrange is part of the num-utils package, which is copyrighted by Suso Banderas and released under the GPL license. Please read the COPYING and LICENSE files that came with the num-utils package Developers can read the GOALS file and contact me about providing submitions or help for the project. MORE INFO
More info on numrange can be found at: http://suso.suso.org/programs/num-utils/ perl v5.10.1 2009-10-31 NUMRANGE(1)
All times are GMT -4. The time now is 09:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy