I am using readdir() in Ubuntu to display files and directories. The weird thing is readdir() displays some files starting with "dot", and some that end at ~ . But these files are not in my specified directory.
What are these files?
I was wondering when reading names of files, will these weird files will also be mentioned by d_name or not?

Regards
readdirreads all files present within the folder, whilelsonly list non-hidden files. Try to list your files withls -a, and you will see those files.