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

  • Home
  • SEARCH
  • 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 7195193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:31:46+00:00 2026-05-28T20:31:46+00:00

#include <stdio.h> char converter(char input[]); char getInformation (char input[]); int main(){ char c[99]; int

  • 0
#include <stdio.h>

char converter(char input[]);
char getInformation (char input[]);

int main(){

  char c[99];
  int i;

  printf("Enter a Line:");
  scanf("%c", &c);

  while(i < 99){
    printf("%c\n", &c[i]);
    i++;
  }

}

Results for when I tried to run this

z:~/homework1: gcc -o hw1_1 hw1_1.c
z:~/homework1: hw1_1
Enter a Line:Test
Ø
Ù
Ú
Û
Ü
Ý
Þ
ß
à
á
â
ã
ä
å
æ
ç
è
é
ê
ë
ì
í
î
ï
ð
ñ
ò
ó
ô
õ
ö
÷
ø
ù
ú
û
ü
ý
þ
ÿ





































1
2
3
4
5
6
7
8
9
:
z:~/homework1:

I’m trying to get it to read a text and print it out. Is there a way I can set the array to undefined number and how would I implement that into the while loop? Also can I have some guidance of how to check every character and change it’s case (from lower case to upper case and the other way around). I think I can do this by checking the ASCII value of the character and flipping the numbers. For example if the character is a decimal value from 65-90, which are A-Z, I would add 32 to it to make it small. For character from 97-122, a-z, I would subtract 32. I don’t need the answer but some hits would be nice. Thank you.

So far I’ve made these changes.

#include <stdio.h>

char converter(char input[]);
char getInformation (char input[]);

int main(){

  char c[30];
  int i;

  printf("Enter a Line: ");
  fgets(c, sizeof(c), stdin);


  i=0;
  while( i < sizeof(c)){
    printf("%s", c[i]);
    i++;
  }

}

This is what I get after trying to run this.

z:~/homework1: gcc -o hw1_1 hw1_1.c
z:~/homework1: hw1_1
Enter a Line: Test
Segmentation fault (core dumped)
z:~/homework1: z:~/homework1:

Yes I got it! thanks a lot everyone!! Here is the code

    #include <stdio.h>

int main(){

  char c[BUFSIZ];
  int i;

  printf("Enter a Line: ");
  fgets(c, BUFSIZ, stdin);

  i=0;
  for (i=0; i < sizeof(c); i++){

    if ((c[i] >= 65) && (c[i] <= 90) ){
      c[i] = c[i]+32;
    }else {
      if ((c[i] >=97) && (c[i] <= 122) ){
        c[i] = c[i]-32;
      }
    }
  }

and the results when I run it:

z:~/homework1: gcc -o hw1_1 hw1_1.c
z:~/homework1: hw1_1
Enter a Line: TeoijsTY;' ';lasd
tEOIJSty;' ';LASD

z:~/homework1:

This is the best feeling you can have, writing a working code! I wonder if I post this and my professors does a Google check of my code and think that I plagiarized? Anyways thanks a lot for the help.

  • 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-28T20:31:48+00:00Added an answer on May 28, 2026 at 8:31 pm

    When you read in a line via scanf, you use the format specifier for a char, you should use %s or, preferably, %98s to avoid overflow. On the other hand, when printing the characters one by one, you should pass the character itself as an argument to printf and not its address, so there it should be printf("%c\n",c[i]);.

    To avoid printing out more characters than have been read in, you can first zero-fill the char-array, then scan with a width less than the array size to guarantee that you have a 0-terminated string in the array, and in the printing loop, check that c[i] != 0.

    For the case conversions, the header <ctype.h> contains the necessary functions, that’s better than to code them yourself. If you’re not allowed to use them, your plan with the comparison with 'A' = 65 etc. works well for ASCII characters, but you may need to also consider characters in the range 128-255 (depends on your assignment).

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

Sidebar

Related Questions

consider the code #include<stdio.h> int main(void) { char* a; scanf(%s,a);//&a and &a[0] give same
#include <stdio.h> int main() { char read = ' '; while ((read = getchar())
The following C program: #include <stdio.h> int main(void) { printf("%u %u %u\n",sizeof "",sizeof(""+0),sizeof(char *));
#include<stdio.h> int main() { char a[5]=hello; puts(a); //prints hello } Why does the code
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { // int char str[40],ch; FILE*fp,*fp1,*fp2; fp=fopen(ide_input,w); fp1=fopen(error_log,w); fp2=fopen(lex_output,w);
#include<stdio.h> #include<zlib.h> #include<unistd.h> #include<string.h> int main(int argc, char *argv[]) { char *path=NULL; size_t size;
#include <string.h> #include <stdlib.h> #include <stdio.h> int main(void) { unsigned char *stole; unsigned char
Today I found the following: #include <stdio.h> int main(){ char x = 255; int
Here is my code!(sorry for my poor english) #include<stdio.h> int convert(char ch); int main(void)
Source: #include <stdio.h> void main() { int i, j, tree_Size, spaces, total_Spaces, x; char

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.