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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:44:15+00:00 2026-06-15T05:44:15+00:00

Here is my code to print the string char accname[MAX][MAXSTRING], transname[MAX][MAXSTRING]; printf (Enter title

  • 0

Here is my code to print the string

char accname[MAX][MAXSTRING], transname[MAX][MAXSTRING];

printf ("Enter title for new account: ");
accname[i][i] = validatestring();
printf ("\n");

printf ("Enter title for transaction: ");
transname[i][i] = validatestring();
printf ("\n");

printf ("%s  %s", accname[i], transname[i]);

my code for validatestring()

char validatestring() {
    int keeptrying = 1, rc;
    char i[31];
    do
    {
        rc = scanf("%30[^\n]", &i);
        if (rc == 0)
        {
            printf (" **Invalid input try again: ");
            clear();
        }
        else if (getchar() != '\n')
        {
            printf (" **Title is longer than 30 characters: ");
            clear();
        }
        else
        {
            keeptrying = 0;
        }
    } while (keeptrying == 1);
    return i;
}

at the printf stage for accname[i] / transname[i] i don’t get the value I entered, I get weird conversion string types, sometimes I got the first character of my input but now I get something completely different. Can anyone figure out why?

  • 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-15T05:44:16+00:00Added an answer on June 15, 2026 at 5:44 am

    Your validatestring function is hopelesely broken.

    Firstly, you declared validatestring as returning char. Yet you attempt too return a char * from it (see return i, where i is char [31]). This should not even compile.

    Secondly, if you intend to return a string from validatestring, you have to make sure that you are not returning a pointer to a local buffer from it. i is a local array. A pointer to i cannot be returned from validatestring.

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

Sidebar

Related Questions

Here is my simple code : #include <stdio.h> int main(){ printf(Hello new world\n); char
I check like this: enter code here var point = new g.LatLng(parseFloat(lat),parseFloat(lng)); var bounds
Here is my code: void subroutine(const char *message) { printf(message); } And here is
Here's my code that is not working: print To: ; my $to=<>; chomp $to;
Here is the code, it's pretty straightforward. class Foo { public: void print() {
How do I print the ms access data(.mdb) in vb.net? Here is the code
I have this code here printf '$request1 = select * from whatever where this
Here is the normal code : if(a==b) printf(equal); else if(a>b) printf(bigger); else printf(smaller); My
Here is a simple code to print all characters of a txt file on
Here is my code: #include <stdio.h> #include <string.h> #include <errno.h> int cmp(const void *a,

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.