I am not sure what this means and I get it all the time. Can someone help me fix this code?
[ char add_account(account_t a[])
7 {
8 int i, N=1000000;
9 char ch;
10 char str1, str2;
11 int m=20;
12
13 for(i=0;i<N;i++)
14 {
15 if(a.number==0)
16 {
17 printf("Enter first name\n");
18 fgets(str1, m, stdin);
19 strcpy(a.first, str1);
20 printf("Enter middle initial\n");
21 getchar();
22 ch=a.mid;
23 printf("Enter last name\n");
24 fgets(str2, m, stdin);
25 strcpy(a.last, str2);
26 printf("Enter new account number\n");
27 scanf("%d", &a.number);
28 printf("Enter opening balance\n");
29 scanf("%f", &a.balance);
30 }
31 else printf("No more new accounts accepted\n");
32 }
33 return a;
34 }
]
alcx88
0
Newbie Poster
Recommended Answers
Jump to PostI am not sure what this means and I get it all the time.
Really and what would that be?
Can someone help me fix this code?
What's wrong with it beside not having code tags?
Jump to Postbecause your first arguments to fgets are all single characters.
the argument is supposed to be a STRING. not a single character. a single character is actually an 8-bit integer, so it thinks you are passing in an integer when it expects the starting position of a string (aka …
Jump to Postit's cool. let us know if that doesn't fix your problem.
All 11 Replies
gerard4143
371
Nearly a Posting Maven
alcx88
0
Newbie Poster
jephthah
1,888
Posting Maven
alcx88
0
Newbie Poster
jephthah
1,888
Posting Maven
alcx88
0
Newbie Poster
jephthah
1,888
Posting Maven
alcx88
0
Newbie Poster
jephthah
1,888
Posting Maven
Aia
1,977
Nearly a Posting Maven
jephthah
commented:
thanks, good catch.
+6
jephthah
1,888
Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.