Unix Programming - 2 questions: directory search and user creator

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2005 > 2 questions: directory search and user creator





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author 2 questions: directory search and user creator
darkchild50@gmail.com

2005-11-16, 8:48 pm

Q1. i have found a good number of directory display programs but cant
seem to fiugre out how to find a file useing a simmalir program. any
ideas.

ps. i run fedora core.

Q2. im trying to impliment a program that looks in a file for a list of
usernames and passwords in the format
username1 password1
username2 password2
ect.
the code i wrote to do this is:

#include <stdio.h>

int main(){
FILE *fp;
char ch;

fp = fopen("users.cfg", "r");
ch = fgetc(*fp);
while(ch != EOF){
while(ch != " "){
/* this part needs to add th char ch to a string usrn*/
}
while(ch != "\n"){
/* this part needs to add th char ch to a string pass*/
}
}
}

any ideas?


- darkchild

SM Ryan

2005-11-16, 8:48 pm

darkchild50@gmail.com wrote:
# Q1. i have found a good number of directory display programs but cant
# seem to fiugre out how to find a file useing a simmalir program. any
# ideas.

You might want to include at least partial code.

# Q2. im trying to impliment a program that looks in a file for a list of
# usernames and passwords in the format
# username1 password1
# username2 password2
# ect.
# the code i wrote to do this is:
#
# #include <stdio.h>
#
# int main(){
# FILE *fp;
# char ch;
#
# fp = fopen("users.cfg", "r");
# ch = fgetc(*fp);
# while(ch != EOF){
# while(ch != " "){

You're comparing a character to a string address. To get the
character codes of space and newline use single quotes,
' ' and '\n'. You might want to review the distinction of
single and double quotes in C.


# /* this part needs to add th char ch to a string usrn*/
# }
# while(ch != "\n"){
# /* this part needs to add th char ch to a string pass*/
# }
# }
# }

--
SM Ryan http://www.rawbw.com/~wyrmwif/
I think that's kinda of personal; I don't think I should answer that.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com