8 character length UUID [duplicate] - uuid

This question already has answers here:
Generating 8-character only UUIDs
(9 answers)
Closed 2 years ago.
I'm making ticket system and would want to know generate random 8 character length UUID. I've searched a bit and found that UUID has types between 1-4.
Mu questions
How unique is type 1 UUID?
Should I generate type 4 UUID and get first 8 character?
Should I use UUID for generate 8 character length unique id?

A UUID is 128 bits, commonly displayed as a 36-byte hexadecimal string. If you throw away some (in your case, most) of the bits, it is no longer a UUID.
If you just want 8 random bytes, use your language's native function to generate that.

Related

data types to store large numbers in C [duplicate]

This question already has answers here:
Store and work with Big numbers in C
(3 answers)
Closed 8 years ago.
I want to store a number "x" where 0<=x<=(10^18).
Which datatype should be used in C for storing such a large number?
I used "long int" but it's not working..
Use unsigned long long int. It is supported in C99 or later, and as a compiler extension in some pre-1999 compilers. and it must be able to hold at least 1.8 * 10^19 values.

Representing UTF-8 in ASCII [duplicate]

This question already has answers here:
UTF-8 -> ASCII in C language
(5 answers)
Closed 9 years ago.
I am trying to code a lexer for language "go" in "C".But "go" used UTF-8 as it's character set and C used Ascii. So is it possible to represent the unicode characters in ascii?
C has a support for multibyte strings, but you have to mess with locales for it to work.
ASCII is actually a subset of UTF-8, so you can use standard C singlebyte string functions to some extent. Just remember that functions requiring or returning lengths are byte counts, not character counts.
For anything more sophisticated, you'll need external library.

Reading in to a character array of unknown size [duplicate]

This question already has answers here:
C dynamically growing array
(10 answers)
Closed 9 years ago.
How do I read in a c-string in to a character array without knowing the size of the string that the user will enter ?
Without any code or further description of your issue it's hard to know what you're trying to achieve, but, one of the following might be appropriate for your needs:
Use a preallocated array of some maximum size you know is greater than the number of characters that will be entered.
Create an empty std::string, and then use the string "+=" operator for each character entered. Then you can convert back to an array using the c_str() method.

What is a bit vector? [duplicate]

This question already has answers here:
C/C++ Bit Array or Bit Vector
(5 answers)
Closed 9 years ago.
I looked online for a good while now, and can't seem to find a good example of what a bit vector actually is.
I have an assignment to do for college which is to add, remove, union of 2 vectors and the intersection too. But I am struggling to comprehend what an actual bit vector is. I am using C to write this.
Could someone please help me on this, it would be a massive help.
Bit vector is a structure which purpose is an accessability of individual bits. Implementation-wise it can be an integer array with some function provided for addressing and manipulation of individual bits of the array. To the final user the array has to look as a "string" of bits, and the functions have to be able to access arbitrary nth bit of the "string".
There is a bitset class in the standard library of C++ which represent this concept, but I am not aware of some option in C language.

ranged random numbers in C [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to generate a random number from within a range - C
I'm looking for something I can use in C that will give me a random number between a and b. So something like rand(50) would give me a number between 1 and 50.
From the comp.lang.c FAQ: How can I get random integers in a certain range?
You can use either rand or random to get an arbitrary random value, then you can take the result of that and mod it by the size of the range and then add the start offset to put it within the desired range. Ex:
(rand()%(b-a))+a
You need to use rand() and srand().
http://linux.die.net/man/3/rand

Resources