changing alphabet order

This is a discussion on changing alphabet order within the C Programming forums, part of the General Programming Boards category; i want to creat a new string with other alphabet order for example instead of starting with a to start ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    1

    changing alphabet order

    i want to creat a new string with other alphabet order
    for example instead of starting with a to start with r(order o 3)and end with abc
    Code:
    int main(void)
    {
      char alf[]="abcdefghijklmnopqrstuvwxyz";
      char ncifra[ALF];
      int i,j,nchave;
      
      printf("Chave (posicoes a transpor):");
      scanf("%d",&nchave);
               
      for(i=nchave;i<ALF;i++) {
         j=0;
         ncifra[j]=alf[i];
         j++;
      }
      for(i=0;i<nchave;i++) {
         j=26-nchave;
         ncifra[j]=alf[i];
         j++;
      }
    return 0;
    }

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    What's your question?

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Code:
    int main(void)
    {
      char alf[]="abcdefghijklmnopqrstuvwxyz";
      char ncifra[ALF];
      int i,j,nchave;
      
      printf("Chave (posicoes a transpor):");
      scanf("%d",&nchave);
               
      for(i=nchave;i<ALF;i++) {
         j=0;
         ncifra[j]=alf[i];
         j++;
      }
    j gets reset inside each iteration of the for-loop; you should set j=0 outside.
    Code:
      for(i=0;i<nchave;i++) {
         j=26-nchave;
         ncifra[j]=alf[i];
         j++;
      }
    return 0;
    }
    [/QUOTE]
    Ditto.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laplace Expansion
    By Leojeen in forum C Programming
    Replies: 7
    Last Post: 10-28-2008, 11:26 PM
  2. alphabet order problem(Datafile)
    By korena in forum C Programming
    Replies: 2
    Last Post: 08-31-2008, 08:09 AM
  3. Alphabet not changing
    By swgh in forum C Programming
    Replies: 5
    Last Post: 05-25-2007, 03:32 PM
  4. changing byte order of an unsigned long?
    By stustu92 in forum C Programming
    Replies: 6
    Last Post: 01-27-2006, 05:21 AM
  5. Changing Tab Order
    By Tesita in forum Windows Programming
    Replies: 1
    Last Post: 01-11-2002, 07:43 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21