Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:15:17+00:00 2026-06-02T15:15:17+00:00

ok i have incluced my structure as well as my pointer, here is what

  • 0

ok i have incluced my structure as well as my pointer, here is what i am trying to figure out, i need to store up to 5 peoples profiles, but i do not know how to store these in my array while using a pointer
if i don’t have the pointer i can do it like this:
strcpy(user[0].UserName,”whatevername”);
strcpy(user[0].UserName,”whateverpwd”);

but how do i specify where in the array i want the info while using a point that points to my structure.. i hope this makes sense i don’t think i can explain it any better

struct profile
{
char First[15];
char Last[15];
char Pwd[10];
char UserName[10];
};

struct profile user[100];
struct profile *puser;
puser=&user[0];



void add_user(struct profile *puser)
{
 int i = 0;
 int j = 0;
 int quit = 0;
 char fname[30];
 char lname[30];
 char username[30];
 char password[30];

 do
 {
 printf("Enter the first name of the user:\n");
 fgets((puser+i)->First,15, stdin);
 printf("Enter the last name of the user:\n");
 fgets((puser+i)->Last, 15, stdin);
 printf("Enter the username:\n");
 fgets((puser+i)->UserName, 30, stdin);
 printf("Enter the password:\n");
 fgets((puser+i)->Pwd, 30, stdin);


 printf("the first name is: %s\n", (puser+i)->First);
 printf("the last name is: %s\n", (puser+i)->Last);
 printf("the user name is: %s\n", (puser+i)->UserName);
 printf("the password name is: %s\n", (puser+i)->Pwd);
 j++;
 printf("enter 0 to exit 1 to continue:");
 scanf("%d", &quit);
 if(quit == 0)
 printf("goodbye");
 i++;
 getchar();
 }while(quit == 1);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:15:18+00:00Added an answer on June 2, 2026 at 3:15 pm

    Try this:

    #include <stdio.h>
    
    typedef struct
    {
    char First[15];
    char Last[15];
    char Pwd[10];
    char UserName[10];
    }profile;
    
    profile user[100];
    profile *puser = user;
    
    void add_user(profile *puser);
    
    void add_user(profile *puser)
    {
     int i = 0;
     int j = 0;
     int quit = 0;
     char fname[30];
     char lname[30];
     char username[30];
     char password[30];
    
     do
     {
    
         printf("Enter the first name of the user:\n");
         fgets(puser[i].First,15, stdin);
         printf("Enter the last name of the user:\n");
         fgets(puser[i].Last, 15, stdin);
         printf("Enter the username:\n");
         fgets(puser[i].UserName, 30, stdin);
         printf("Enter the password:\n");
         fgets(puser[i].Pwd, 30, stdin);
         printf("enter 0 to exit 1 to continue:");
    
         scanf("%d", &quit);
         getchar();
         i++;
     }while(quit == 1);
    
     for( j = 0; j < i; j++ )
     {
    
         printf("first name[%d] is: %s\n", j,(puser+j)->First);
         printf("last name[%d] is: %s\n", j,(puser+j)->Last);
         printf("user name[%d] is: %s\n", j,(puser+j)->UserName);
         printf("password[%d] is: %s\n", j,(puser+j)->Pwd);
     }
    
     printf("Goodbye\n");
    
    }
    
    
    int main(int argc, char *argv[])
    {
    
        add_user(puser);
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Preface: This is not much about how to structure code within files. I have
I'm trying to figure out how to create additional calculated properties that are exposed
I am facing a weird problem I have defined I a structure in a
I have written a few apps for the iphone now, but they are all
Currently I have a legacy based non-MVC php framework which I need to update
I have a simple table structure where each item row has a status. What
I have a directory structure that looks like this: basedir/dir1/dir2/dir3/dir4/myzip/subdirs I would like to
If I have a directory structure like this: - index.php - public - img
What's the deal? I am trying to animate a color property, so I have
I am trying to use the GPS_DEVICE structure from within .NET CF 3.5 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.