• This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #167
    admin
    Keymaster

      While working on Caesar project, this is my current code:

      
      
      #include<stdio.h>
      #include<cs50.h>
      #include<string.h>
      #include<ctype.h>
      int main(void)
      {
      string name = get_string("Enter: ");
      printf("Entered text by user: %s\n", name);
      int n = strlen(name);
      printf("length of entered text: %i\n", n);
      int key = get_int("enter key: ");
      char newuppercase_array[n];
          for (int i = 0; i < n; i++)
          {
              if (isupper(name))
              {
              newuppercase_array = ((((name - 65) + key)%26) + 65);
              }
              else
              {
              newuppercase_array = name;
              }
              printf("%c",newuppercase_array);
           }
      }

       

      r/cs50 - How to get $ in a new line

       

      Now, how to get $ prompt in a new line. I tried with this but not successful:

      
      
      printf("%c\n",newuppercase_array);

      r/cs50 - How to get $ in a new line

       

      Is there is a need to create a new string variable/array and then use printf?


      Reply


      Outside your loop simply do:

      print newline after for loop ends.

       

       

       

       

       

       

       

       

       

      [learn_press_profile]

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