• This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #147
    admin
    Keymaster
      
      
      #include<stdio.h>
      #include<cs50.h>
      #include<string.h>
      int main(void) 
      {
      string name = get_string("Enter: ");
      printf("%s\n", name);
      int n = strlen(name);
      printf("%i\n", n);
          for (int i = 0, i < n, i++)
          while name != ("\0");
          printf("%i", name);
      
      }

      Getting this error message (with helpcs50 make caesar):

      
      
      Asking for help...
      
      caesar.c:10:16: error: redefinition of 'i'
      
      Not quite sure how to help, but focus your attention on line 10 of caesar.c! caesar/ $

      Unable to figure out redefinition of i, i is not defined earlier in this code. %i on the previous line is something different.

      Update:

      After getting replies and reworking, here is the code that seems to achieve the intermittent goal of finding ASCII code of entered characters. There was no need of while loop and it was an error as the same leads to infinite loop. Even if there was a need, I should perhaps have opted for if command.

      
      
      #include<stdio.h>
      #include<cs50.h>
      #include<string.h>
      int main(void) 
      {
          string name = get_string("Enter: ");
          printf("Entered text by user: %s\n", name);
          int n = strlen(name);
          printf("lenght of entered text: %i\n", n);
          for (int i = 0; i < n; i++)
          {
              printf("ASCII code %i\n", name);
          }
      }


      Reply


      https://edstem.org/us/courses/176/discussion/996396[learn_press_profile]

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Scroll to Top