473,395 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Variable Truncation

46
Hi,

How do I truncate a variable to a certain size? For instance, the integer "12345" truncated to "123", so that it has only three numbers. Or the string "Hello World" to just "Hello" so it has just five characters. I'm using C++.

Thanks,
Sake
May 10 '07 #1
2 1376
gpraghuram
1,275 Expert 1GB
HI,
You can use the string class in C++ to achieve this.
string class has a method named substr which will be useful to u
Thanks
Raghuram
May 10 '07 #2
DeMan
1,806 1GB
and integers can be truncated by dividing by powers of 10
eg 12345/10 = 1234
May 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve Bright | last post by:
In an ASP page, I am using the FileSystemObject OpenTextFile method to initiate a TextStream object. In some files I have long lines and it appears that these are being truncated to 2048...
7
by: | last post by:
How to call a function with variable argument list from another function again with variable argument list? Example : double average ( int num, ... ); double AFunct1 ( int num, ... ); double...
1
by: hharry | last post by:
Hello All, I am attempting a bulk load of fixed position flat file data via bcp and I have noticed that I get a Right Truncation error when trying to load a row where the last column value is...
11
by: persevere | last post by:
#include <stdio.h> void main ( void ) { int *p, *q; p = q + 200; printf("%d %d %d %d", p, q, (int)p, (int)q); } The result is, "400 1439 0 1439".
4
by: ma740988 | last post by:
In a vendor file I'm given: /* start vendor_file.c */ #ifdef __cplusplus typedef void (*VOIDFUNCPTR) (...); /* pfunc returning void */ #else typedef void (*VOIDFUNCPTR) (); /* pfunc...
10
by: joel.brewster | last post by:
We have a VB6 application using ADO version 2.5 and I am receiving a " CLI0109E String data right truncation. SQLSTATE=22001" error when I execute the rs.UpdateBatch method. I have determined...
2
by: Magix | last post by:
Hi, I have following code. char buffer; void string_addchar(char *sourc, char ch) { int length; length=strlen(sourc);
26
by: Alfonso Morra | last post by:
Hi, I'm getting a compiler error of "pointer truncation from 'void *' to 'int'" because I'm not explicitly casting from void* to (datatype*). Pointers are stored as ints (is that right?), so as...
0
by: Galal | last post by:
Does DB2 Net Search Extender support right truncation, left truncation in Arabic, left truncation in English, or right truncation in Arabic?
2
by: coolnoff | last post by:
I have a dts which creates a table which is utilized on my local intranet. The DTS runs without error and the table is created/populated/transfered to the appropriate db. Then it appears that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.