Skip to content
Advertisement

Segmentation fault (core dumped) C linux

So i have to make a program that execution results are similar to those after using command who and who am i in linux. the problem is that both functions inside if(strcmp… and in else… are working when separated.

The main issue is that i have to have them both in one file, and it just not work. When put together only that do something ./program am i, and ./program tells Segmentation fault (core dumped).

Second issue is that i have no clue how to make part ./program am i work properly it should return me only me: User pts/0 date time… not all of users like in else… part.

JavaScript

Advertisement

Answer

Why don’t you try using,

JavaScript

Directly openning and seeking utmp file is not recommended. An utmp file seems to be a normal file that can freely access, but it behaves like a database.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement