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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:03:15+00:00 2026-06-07T06:03:15+00:00

I have this small program: #include <stdio.h> #include <string.h> #include <ctype.h> #define SIZE 30

  • 0

I have this small program:

#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define SIZE 30

void inverti (char s);

int main ()
{
        char str[SIZE+1];

        gets(str);

        printf ("Your imput: ");
        puts(str);

        invert(*str);

        printf ("It works!");

        return 0;
}

void invert (char s)
{
    int i;

    for (i = 0; i < SIZE + 1; i++)
    {
        if (isupper(str[i]))
            str[i] = tolower(str[i]);

        else if (islower(str[i]))
            str[i] = toupper(str[i]);
    }

    puts(str);
}

were is the error? Why i can’t pass str to my function?

In function ‘main’:|
warning: passing argument 1 of ‘inverti’ makes integer from pointer without a cast [enabled by default]|
note: expected ‘char’ but argument is of type ‘char *’|
In function ‘invert’:|
error: ‘str’ undeclared (first use in this function)|
note: each undeclared identifier is reported only once for each function it appears in|
||=== Build finished: 3 errors, 1 warnings ===|
  • 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-07T06:03:16+00:00Added an answer on June 7, 2026 at 6:03 am

    Your code has at least 3 problems.

    First, and most relevant to your specific question, you’ve declared the argument to your function as a single character: char. To pass a C string, declare the argument as char * – a pointer to a character is the type also used for a C string:

    void invert(char *str)
    

    And you won’t need to dereference when passing the argument:

    invert(str);
    

    Also note that you’ve mis-typed the name of the function in your function prototype: you’ve called it inverti there. The name in the prototype must match the name in the function definition later in the code.

    You’ll also need to change the argument type in your corrected and renamed function prototype:

    void invert(char *str);
    

    Your code has one additional problem: you’re iterating over the string using SIZE. SIZE is the maximum size of your array, but not necessarily the size of your string: what if the user types in only 5 characters? You should review and use the function strlen to get the actual length, and in your loop, only iterate over the actual length of your string.

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

Sidebar

Related Questions

I have this small C program (play.c): #include <stdio.h> main() { int t; for
Suppose I have the following program: #include <stdio.h> int main() { printf(This is a
I created a small program, as follows: #include <math.h> #include <stdio.h> #include <unistd.h> int
I have written small C++ console application and this is source code : #include<stdio.h>
I have this small class looking like this: private static int field1 = -
I have this string: small: http://img.exent.com/free/frg/products/666550/player_boxshot.jpg boxshot: http://img.exent.com/free/frg/products/666550/boxshot.jpg I want to get only the
I have this small program that reads a line of input & prints the
I have a problem with this small program. It added some value to list.
I have this small class called City that simply holds some information about a
I have this small snippet to change a bit of html when a user

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.