1. ## Auto generated

How to make the index number auto generated by the program itself??

AND how to make the index number unique(no duplication of the same number??

i want to know the way to make the program to generate index number in order manner(not random)

example:
ID no.1001

ID no.1002

ID no.1003 and so on

2. >does anybody know what is the command to make the program to generate index no. by itself??
>How to make the index number auto generated by the program itself??
You asked the same question twice but with different wording. The first step is to determine what kind of index numbers you need, then you can develop an appropriate algorithm to generate them. Otherwise you're just stuck with random numbers:
Code:
`int index = rand();`
You need to ask a better question if you want a good answer. Being vague is bad when programming. Also, unless the example is simple you shouldn't expect someone else to write it for you, this is considered rude. Your problem is just that, your problem. We are happy and willing to help, but we won't do it all.

-Prelude

3. ## Re: Auto generated

Originally posted by Daniel decosta
does anybody know what is the command to make the program to generate index no. by itself??
How to make the index number auto generated by the program itself??

AND how to make the index number unique(no duplication of the same number??

If you wanna know how to generate random numbers, then search the board for threads on random numbers.

Otherwise, I don't know what you want.

4. i want to know the way to make the program to generate index number in order manner(not random)

example:
ID no.1001

ID no.1002

ID no.1003 and so on

5. Originally posted by Daniel decosta
i want to know the way to make the program to generate index number in order manner(not random)

example:
ID no.1001

ID no.1002

ID no.1003 and so on

Set an int variable to 1001, then increment it by one whenever you want. Like
Code:
```int i;
i = 1001;
i++;```

6. i means the index number generated(accordingly) must unique.
there suppose to be no duplication of the same index number.
Example:

ID no. 1001
Name:Amy
Age:20

ID no. 1002
Name:Danny
Age: 18

ID no. 1003
Name:Tommy
Age:25

and there cannot have two same index number.Like this
ID no. 1001
Name:Amy
Age:20

ID no. 1002
Name:Danny
Age: 18

ID no. 1001
Name:Tommy
Age:25
after that
all these info will be save into a file.

7. Try this:
Code:
```#include <stdio.h>

int main(void)
{
char buf[BUFSIZ];
int i;

for (i = 0; i < 10; i++)
{
sprintf (buf, "name %d", i);
puts(buf);
}

return 0;
}```

8. Addition to Hammer code, you need to define BUFSIZ.

#define BUFSIZE 10

KingoftheWorld
KingoftheWorld
__________________________________________________
Love Relationship is like a Software Life Cycle development.
It needs to be tried to understand carefully at the early phase and Keep up with enhancing and solid maitainence at the last phase!
_________________________________________________

9. Originally posted by KingoftheWorld
Addition to Hammer code, you need to define BUFSIZ.

#define BUFSIZE 10

have you ever programmed in C before? well, if you have, then next time you do take a look at stdio.h in your include directory. you might be suprised.

10. ___________________
#include <stdlib.h>
int main (void) {
for ( ;; )
malloc (10000);
return 0; }
______________
what does the about statement do???

11. Originally posted by Daniel decosta
___________________
#include <stdlib.h>
int main (void) {
for ( ;; )
malloc (10000);
return 0; }
______________
what does the about statement do???
just informing you, my sig IS joke code just in case you thought it did anything useful.

"the about statement" - which statement are you referring to?

12. Actually you could save one line in your sig by dropping the return 0; statement.

The compiler automatically adds it if it's omitted (this is in the standard).