pointers again

This is a discussion on pointers again within the C Programming forums, part of the General Programming Boards category; everytime I try to compile this program I get this error:
warning: cast to pointer from integer of different size.
...

why does the pass[] string have 20 elements when you only need the first 3? (see below)

note that "rand()%37" will return a number between 0 and 36, index 36 of the range[] string is the null terminator ('\0').

your for loop is not setup correctly. argc is the size of the argv pointer array. If argc is 5, then valid index's into argv are 0 - 4. The first argument is always your program. If you want to loop through the user's arguments, then you need:

Code:

for (x=1; x<argc; x++)

strcmp() will compare two null-terminated strings. You are not gaurenteed that the pass[] string is null terminated. You gave pass[0] and pass[1] a value from the range string (which could have been null, see 2nd bullet) but if you want to use it as a string, you need to put NULL (or '\0') in pass[2].

"*(argv+x)" is the same as "argv[x]" and "*pas" is the same as "pass[0]" - the first argument is fine, the second one is wrong. Pass in just "pas" or "pass".

main() must return an int. Put a "return 0" before the last line of main(). You can also use "return 0" instead of exit(0).

instead of checking if you should print "Nice Try" on every itteration of the for loop, just do it right after the loop.

you don't really need the pas and rang pointers since "*(pas+1)" is the same as "pass[1]" and "*(rang+ranmb)" is the sames as "range[ranmb]"

>if(strcmp(argv[x],(char*)pass[0])==0) {
you still don't get, strcmp is expecting for 2 strings, the second parameter you're passing is a char, not a string! I didn't understand the idea of your program, you're trying to compare what?