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 7599459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:40:01+00:00 2026-05-30T22:40:01+00:00

I’m constantly getting this error whenever I try to pass a array of Strucs

  • 0

I’m constantly getting this error whenever I try to pass a array of Strucs into a function.

10: error: expected declaration specifiers or ‘…’ before ‘RECORD’
113: error: conflicting types for ‘edit’
10: error: previous declaration of ‘edit’ was here

I also get a lot of warnings about how I use strlen and strcmp about the arguments and how I’m making a pointer from a int without a cast. Is there anything wrong with this?

Can anyone explain to me what’s wrong with the code I have so far?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLENGTH 51 //longest length of a single record + 1 =51 bytes
#define SIZEOFDB 1000
#define ENCRYPT 5

void add(int argc, char *argv[]);
void del (char *username);
void edit(char *nName, char *nPw, char *nType, char *tName, char *tPw, RECORD *arr);
int verify (char *username, char *password);
void parse (char *record, char *delim, char);

typedef struct rec
{
char name[22];
char pw[22];
char type[6];
}RECORD;

int main(int argc, char *argv[]){
int j;
char tempName[22];
char tempPw[22];
char tempType[6];
char newName[22];
char newPw[22];
char newType[6];
static const char filename[] = "password.csv";
FILE *file;
file = fopen(filename, "r+");

if (file == NULL){
    //create csv file password.csv
    printf("Just created password.csv");
    file = fopen(filename, "w+");
}
size_t i =0, count, size = 1000;
RECORD *arr = malloc(size * sizeof *arr);
if (arr){
    char line[51];
    while(i<size && fgets(line, sizeof(line), file)){
        sscanf(line, "%[^','],%[^','],%s", &arr[i].name, &arr[i].pw, &arr[i].type);
        ++i;
    }

    fclose(file);

    if (strcmp(argv[1], "-menu") == 0){
        //menu function
        printf("MENU\n");
    } else if(strcmp( argv[1], "-add") == 0){
        //add function

        strncpy(newName,argv[2],strlen(argv[2]));
        strncpy(newPw,argv[3],strlen(argv[3]));
        strncpy(newType,argv[4], strlen(argv[4]));

        printf("ADD\n");
    } else if(strcmp( argv[1], "-del") == 0){
        //del function

        strncpy(tempName,argv[2], strlen(argv[2]));

        printf("DEL\n");
    } else if(strcmp( argv[1], "-edit") == 0){
        //edit funciton

        strncpy(tempName,argv[2],strlen(argv[2]));
        strncpy(tempPw,argv[3],strlen(argv[3]));
        strncpy(tempType,argv[4],strlen(argv[4]));
        strncpy(newName,argv[5], strlen(argv[5]));
        strncpy(newPw,argv[6], strlen(argv[6]));
        strncpy(newType, argv[7], strlen(argv[7]));

        printf("EDIT\n");
    } else if(strcmp( argv[1], "-verify") == 0){
        //verify function

        strncpy(tempName,argv[2],strlen(argv[2]));
        strncpy(tempPw,argv[3],strlen(argv[3]));

        printf("VERIFY\n");
    } else {
        printf("SYNTAX ERROR\n");
        return 0;
    }
    for (j = 0; j < i; j++){
        printf("%s,%s,%s\n", arr[j].name,arr[j].pw,arr[j].type);
    }
}
free (arr);



return 0;

}

/*void add(char nName[],char nPw[], char nType[], record *arr,FILE *file; ){
int i,j;
if (arr){
char line[51];
while(i<size && fgets(line, sizeof(line), file)){
sscanf(line, "%[^','],%[^','],%s", &arr[i].name, &arr[i].pw, &arr[i].type);
++i
}

}*/

void edit(char *nName,char *nPw, char *nType, char *tName, char *tPw, RECORD *arr){
int i,j;
int size = (sizeof *arr)/(sizeof arr[0]);
for (i=0; i< size; i++){

if ((strcmp( arr[i].name, *tName) == 0 && strcmp (arr[i].pw, *tPw) == 0)){
for (j=0; j<size; j++){
if (strcmp(*nName, arr[j].name) == 0){
printf("ERROR USERNAME ALREADY EXISTS");
break;
}
}
strncpy(arr[i].name, *nName, strlen(*nName));
strncpy(arr[i].pw, *nPw, strlen(*nPw));
strncpy(arr[i].type, *nType, strlen(*nType));
}
}

}

Thanks

  • 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-05-30T22:40:02+00:00Added an answer on May 30, 2026 at 10:40 pm

    You need to declare the RECORD structure before you use it in a parameter list. That is, you should move it to before the forward declarations of your functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from

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.