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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:51:33+00:00 2026-05-27T00:51:33+00:00

#include <stdio.h> #include <ctype.h> /*header for standard tolower function*/ #define STRING_LEN 500 char *

  • 0
#include <stdio.h>
#include <ctype.h> /*header for standard tolower function*/
#define STRING_LEN 500

char * changeCase(char *);
void stripspaces(char*, char*, char*);
int isinteger(char*);
int isHex(char*);
void strrev(char*);


int main(void)
{
    char line[STRING_LEN];
    char line1[STRING_LEN];     
    char *p1 = line;          
    char *p2 = line;
    int ok, ok2;
    printf("Enter a string of up to %d characters:\n", STRING_LEN);
    while((*p1++ = getchar()) != '\n');

    changeCase(line);
    puts("resulting string is:\n");
    printf("%s", line);
    stripspaces(line, p1, p2);
    ok = isinteger(line);
    if (ok)
    {
        printf("%s is an integer\n", line);
    }
    else
    {
        printf("\n%s is NOT an integer\n", line);
    }   
    ok2 = isHex(line);
    if (ok2)
    {
        printf("\n%s is a hex value \n", line);
    }
    else
    {
        printf("\n%s is NOT a hex value\n", line);
    }   

     strrev(line); 

     printf("string is:");
     printf("%s", line);  


    getch();    
    getch();
    return 0; 
}/*end main*/

char * changeCase(char *s){ 

    char *ptr;
    ptr = s;                /* point to start of string*/
    while ( *s != '\0')     /*keep going until you reach nul (end of string)*/
    {

          if(!isdigit(*s))
          {

                      if(isupper(*s))
                      {

                                 *s = tolower(*s);

                      } 

                      else if (islower(*s))
                      {

                                 *s = toupper(*s);

                      }
                      }                
        s++;                /*move to the next character*/
    }
    return ptr;             /* return lowercase version of the string*/

}/*end stringToLower*/

void stripspaces (char *s, char *x1, char *x2){ 
   *x1 = '\0';                 
   x1 = s;                
   while(*x1 != '\0')    
   {    
     if(*x1 == ' ')  
     {                    
       ++x1;              
       continue;  
     }  
     else   
       *x2++ = *x1++;   
   }  
   *x2 = '\0';          
   printf("\nWith the spaces removed, the string is now:\n%s\n", s);  
}

int isinteger(char *s)          /* s is a string */
{                   /* function returns 1(true) or 0(false) */

    if(*s == '+' || '-' || ' '){
          s++;
          } 

    while (*s != '\0')
    {       

        if (!isdigit(*s)) 
        {
                          return 0; 

                          }

        s++;            /* move to next character */
        return 1;
    }


    }
int isHex(char *s)
{

  while (*s != '\0'){
  if (!isxdigit(*s)){

  return 0; 

                       }
  else {

  return 1; 

       }   s++; }
} 
void strrev(char *p) 
{ 
int i,j; 
j = strlen(p);
char temp; 

for (i = 0; i < j; i++) // subscript i goes halfway
{
temp = p[i]; // swap
p[i] = p[j-1-i]; // opposite
p[j-1–i] = temp; // elements
}
}

this program is coming up with an error in the swap function at “p[j-1–i] = temp;” the error is as follows “stray “\150″ in program” wondering how I go about fixing this error

the function containing the error is supposed to reverse string line in memory so that when you print line after the function has been run the string is in reverse. not sure if this actually works, would be useful if someone could also point out any errors I’m making there too.

  • 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-27T00:51:34+00:00Added an answer on May 27, 2026 at 12:51 am

    Take a close look at the second minus in:

    p[j-1–i] = temp; // elements
    

    On my machine it looks like this: –. It’s longer than -, so it’s clearly a different character. The minus character is ASCII 45, whereas the character the compiler is complaining about is ASCII 150.

    To fix, simply replace that line with:

    p[j-1-i] = temp; // elements
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <stdio.h> #include <ctype.h> #define STRING_LEN 500 void stripspaces(char, char, char); int main(void) {
#include <stdio.h> #include <string.h> #include <ctype.h> void delspace(char *str); int main() { int i,
My code #include <stdio.h> #include <stdlib.h> #include <ctype.h> void getData(short int *number, char *string)
#include<stdio.h> #include<ctype.h> int main() { char a,b; FILE *fp; fp=fopen(lext.txt,w); fprintf(fp,PLUS); return 0; }
#include<stdio.h> #include<ctype.h> #include<string.h> int main() { int i=0,j,k,lines_count[2]={1,1},operand_count[2]={0},operator_count[2]={0},uoperator_count[2]={0},control_count[2]={0,0},cl[13]={0},variable_dec[2]={0,0},l,p[2]={0},ct,variable_used[2]={0,0},constant_count[2],s[2]={0},t[2]={0}; char a,b[100],c[100]; char d[100]={0}; j=30; FILE
#include <stdio.h> #include <ctype.h> int isPalindrome( char *str, int length ) { if (
Consider the following code: #include <stdio.h> #include <ctype.h> char* Mstrupr(char* szCad); int main() {
#include <stdio.h> #include <stdlib.h> #include <time.h> void initDeck (int deck[]); void showDeck (int deck[]);
#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<signal.h> #include<stdlib.h> void handler(int signo) { printf(First statement); system(date); exit(EXIT_SUCCESS); } int main()

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.