Thread: Help doing an e-mail program in c...

  1. #76
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    .mail not .MAILR

    you're using:
    Code:
     fgets(ptr[i].MAILR.from,120,fp);
     fgets(ptr[i].MAILR.sub,120,fp);
     fgets(ptr[i].MAILR.msg,120,fp);
     fgets(ptr[i].MAILR.spc,120,fp);
    when it should be:
    Code:
     fgets(ptr[i].mail.from,120,fp);
     fgets(ptr[i].mail.sub,120,fp);
     fgets(ptr[i].mail.msg,120,fp);
     fgets(ptr[i].mail.spc,120,fp);
    and also, you still have the for loop in that function. Get rid of it and just use the i value passed in to the function.
    Last edited by jverkoey; 01-02-2005 at 05:12 AM.

  2. #77
    Registered User
    Join Date
    Dec 2004
    Posts
    45
    Quote Originally Posted by jverkoey
    .mail not .MAILR

    you're using:
    Code:
     fgets(ptr[i].MAILR.from,120,fp);
     fgets(ptr[i].MAILR.sub,120,fp);
     fgets(ptr[i].MAILR.msg,120,fp);
     fgets(ptr[i].MAILR.spc,120,fp);
    when it should be:
    Code:
     fgets(ptr[i].mail.from,120,fp);
     fgets(ptr[i].mail.sub,120,fp);
     fgets(ptr[i].mail.msg,120,fp);
     fgets(ptr[i].mail.spc,120,fp);

    hmm..but I wanted the info coming from "mail.txt" to go to the struct mailr, and the info that the user inputs when writing an email to the struct mail..because the two have to be treatly different, as the written mails are going to be saved in the file, and the ones read from "mail.txt" have to be printf'ed in the screen, and deleted, and viewed...

  3. #78
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    ok.....hmm

    Currently that code above is doing what you're saying. It is getting the contents of the file and storing it to your array. But it appears you want to write and read the entire array, in which case you don't actually want the index parameter for your function, just keep the for loop.

    You'll then want another function that DOES take the int variable saying which index to use and this function will delete/view/edit/whatever that particular email.

  4. #79
    Registered User
    Join Date
    Dec 2004
    Posts
    45
    Quote Originally Posted by jverkoey
    ok.....hmm

    Currently that code above is doing what you're saying. It is getting the contents of the file and storing it to your array. But it appears you want to write and read the entire array, in which case you don't actually want the index parameter for your function, just keep the for loop.

    You'll then want another function that DOES take the int variable saying which index to use and this function will delete/view/edit/whatever that particular email.
    oh..is it doing what I am saying? great then... I'll work now to see if I can get to a point where it gives no errors, and does some of the things expected, as I can't do everything that is asked for...
    thanks a lot!

  5. #80
    Registered User
    Join Date
    Dec 2004
    Posts
    45
    Well, I've been trying but I can't get that errors out... please jverkoey, could you give me your version that compiles with no errors? I have to have that done today at night to be delivered tomorrow, and this way I won't be able to get the grade I need to pass "Programming"... I'm desperate

  6. #81
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Check your private messages.

  7. #82
    Registered User
    Join Date
    Dec 2004
    Posts
    45
    Well people, thanks for all who helped but I can't solve this problem I'm having and I'm sure that what I've done isn't enough for a positive grade... so, next year I'll have to do "programming" again... ...be well

  8. #83
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Quote Originally Posted by Tyler_Durden
    Well people, thanks for all who helped but I can't solve this problem I'm having and I'm sure that what I've done isn't enough for a positive grade... so, next year I'll have to do "programming" again... ...be well
    didn't jverkoey just help you out?
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  9. #84
    Registered User
    Join Date
    Dec 2004
    Posts
    45
    Quote Originally Posted by caroundw5h
    didn't jverkoey just help you out?
    yeah, i talked with him in msn, and he helped me with some stuff, but then he had to get some sleep and is still sleeping...our timeline(dunno if it's the correct word) is very different...I was at midday, and he was at 5 AM...

  10. #85
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    It's clear that you don't have a solid grasp on the areas of C that you're trying to use. To get a "positive grade" you shouldn't need to use anything that you haven't learned in class. So it seems to me that you either weren't paying attention in class or you're trying way too hard to do something that you're not ready to do.

    And there's no sense in trying to make us all feel guilty for "not helping you". We're not here to do your homework for you. Instead, you should be grateful that so many people offered so many suggestions.
    If you understand what you're doing, you're not learning anything.

  11. #86
    Registered User
    Join Date
    Dec 2004
    Posts
    45
    I'm not trying to accuse anybody... If it weren't you I wouldn't be able to do half of what I did... i'm only sad that maybe it isn't enough... And the work was to groups with 2 people, and my colleague quitted, so I had to make the work of 2 people, which was more difficult....
    but don't think i'm not appreciated..i really am..you were all of great help...
    be well

  12. #87
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    I'm awake again by the way...it's kind of hard to give good programming advice at 6 in the morning without any sleep

  13. #88
    Registered User
    Join Date
    Dec 2004
    Posts
    45
    you're not getting it... I'm appreciated for your help.. I thought it would be nice to tell you the status of my situation instead of not saying anything...

  14. #89
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Well, from what you told me last night, so far your program is just pieced together from everyone's advice given here, which in the end is a very bad thing.

    My best advice would be the following:


    1) Don't procrastinate. Programming's not the easiest stuff to do, and especially when you're on a strict time schedule and you don't know what you're doing.
    2) Do NOT ever copy code from anywhere unless you understand it. Doing this will only make you trip over yourself later on as we found last night while I was trying to help you.
    3) Make sure you know what you're doing before you jump in to making a program. I always find it best to brainstorm the ideas of a program and once I have all of the ideas in my head and the general working of the program figured out, I get to work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM