Getting “unixtime” in Java

Avoid the Date object creation w/ System.currentTimeMillis(). A divide by 1000 gets you to Unix epoch. As mentioned in a comment, you typically want a primitive long (lower-case-l long) not a boxed object long (capital-L Long) for the unixTime variable’s type.

Scanner is skipping nextLine() after using next() or nextFoo()?

That’s because the Scanner.nextInt method does not read the newline character in your input created by hitting “Enter,” and so the call to Scanner.nextLine returns after reading that newline. You will encounter the similar behaviour when you use Scanner.nextLine after Scanner.next() or any Scanner.nextFoo method (except nextLine itself). Workaround: Either put a Scanner.nextLine call after … Read more

Implementation of strtok() function

Internal implementation of strtok has already been discussed here: How does strtok() split the string into tokens in C? In your type of implementation ( calling it your type because it is quite different from the actual one), you have not allocated any memory dynamically to the local variable ‘W’. So when you return it, … Read more