What's the difference between size_t and int in C++?
In several C++ examples I see a use of the type size_t where I would have used a simple int. What's the difference, and why size_t should be better? Thank you folks. ...
In several C++ examples I see a use of the type size_t where I would have used a simple int. What's the difference, and why size_t should be better? Thank you folks. ...
I am trying to copy the value in bar into the integer foo. This is what I have so far. When I run it I get a different hex value. Any help would be great. int main() { string bar = "0x00EB0C62"; int foo = (int)bar; cout << hex << foo; ChangeMemVal("pinball.exe", (void*) foo, "100000", 4); return 0; } So the ou...
Had a coworker ask me this, and in my brain befuddled state I didn't have an answer: Why is it that you can do: string ham = "ham " + 4; But not: string ham = 4; If there's an implicit cast/operation for string conversion when you are concatenating, why not the same when assigning it as a string? (Without doing some operator overl...
I'm doing some Project Euler exercises and I've run into a scenario where I have want arrays which are larger than 2,147,483,647 (the upper limit of int in C#). Sure these are large arrays, but for instance, I can't do this // fails bool[] BigArray = new BigArray[2147483648]; // also fails, cannot convert uint to int ArrayList BigAr...
Hi. System.Console.WriteLine(int.MaxValue); This line gives me the answer of 2147483647 as I have a 32-bit PC. Will the answer be same on a 64-bit PC? ...
What is the relation between word length, character size, integer size, and byte in C++? ...
I'm just curious and can't find the answer anywhere. Usually, we use an integer for a counter in a loop, e.g. in C/C++: for (int i=0; i<100; ++i) But we can also use a short integer or even a char. My question is: Does it change the performance? It's a few bytes less so the memory savings are negligible. It just intrigues me if I do a...
Hello, I have a listView on my form.I want to add stuff to it durring the program is running. This is the code I use public void FillList(string[] Name,int[] empty,int[] Population,int[] Max,int[] Check,int size) { if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate { ...
Hi, My Db have some fields using Integer data type, but after SS generated them, all of them 're Boolean db type. Please tell me how to fix it ! Thanks ! ...
This is odd. A co-worker asked about the implementation of myArray.hashCode() in java. I thought I knew but then I ran a few tests. Check the code below. The odd think I noticed is that when I wrote the first sys out the results were different. Note that it's almost like it's reporting a memory address and modifying the class moved ...
I need to write data to a binary file using C's I/O functions. The following code causes a runtime exception : #include "stdio.h" int main(int argc,char* argv[]) { FILE *fp = fopen("path_to_file.bin","wb"); if(fp == NULL) { printf("error creating file"); return -1; } int val = 4; fwrite((const void*)val,s...
I know its possible to get a part of a .txt, then convert it to an integer, then store it in a variable, but is it possible to to that in a single declaration. (The variable needs to be global). Ie: [data.txt] 1020 [convert_data.cpp] #include<fstream> fstream convert("data.txt"); //way to declare something equal to A PARTICULAR POINT i...
I'd like to implement the following logic: function setMyValue (myVar:int = undefined):void { if (myVar == undefined) { /* Generate a value for myVar */ } else { /* Use the supplied value for myVar */ } } So if the value is supplied, use it. If not, generate it. Seems simple enough. Problem is that A...
I want to convert long to int. If the value of long > int.MaxValue, I am happy to let it wrap around. What is the best way? ...
Possible Duplicates: How to convert a single char into an int Character to integer in C Can any body tell me how to convert a char to int? char c[]={'1',':','3'}; int i=int(c[0]); printf("%d",i); When I try this it gives 49. ...
I'm working with .NET strongly-typed datasets and have a table with a nullable int column (and a nullable DateTime column as well). Apparently there is a bug with the dataset designer that prevents having nullable columns on these data types. The designer only allows "throw exception" as the default behavior for null values. Unfortuna...
Hi, I'm going to try to make myself clearer. Why does C# accept the following: object o = "hello"; int? i = o as int?; if (i == null) { // o was not a boxed int } else { // Can use i.Value to recover the original boxed value } and not String = "hello"; int? i = o as int?; if (i == null) { // o was not a boxed int } else { // Can u...
I have and old(ish) C# method I wrote that takes a number and converts it to any base: string ConvertToBase(int number, char[] baseChars); It's not all that super speedy and neat. Is there a good, known way of achieving this in .NET? EDIT: I should clarify - I'm looking for something that allows me to use any base with an arbitrary s...
what would be the easiest way to convert an ArrayList of Integers to one int, with the 1st Integer in the list being the 1st number in the int, etc. in Java? For example an ArrayList of Integers: 1 4 6 7 8 3 8 becomes the int value 1467838 ...
I am trying to write a simple program that asks the user to enter a number and then I will use that number to decide what the cost of the ticket will be for their given age. I am having trouble when trying to convert the string to int. Otherwise the program layout is fine. Any suggestions? thanks using System; class ticketPrice { ...