Thread: copy the index of characters of an array to another array

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    3

    Red face copy the index of characters of an array to another array

    Hello ! my question is located as a comment beside the last printf ! can anybody help ? check the comment near the last printf
    the comment is ==>here i get a sequence of numbers the question is how can i copy this sequence to an array and the print the array out ?

    Code:
    
    
      #include <stdio.h>
                #define N 30
                #define n 100
                int main (void)
                {
                    int i,z,k;
                    int total_chars = 0;
                    char c,seq[N];
                    int tmp[13];
    
                    char Table[] = {'z','c','C','d','D','e','f','F','g','G','a','A','h','c'
                                    ,'C','d','D','e','f','F','g','G','a','A','h','c'
                                   };
    
                      for ( i=0 ; i<n; i++)
                    {
                        c=getchar();
                        seq[i]=c;
                        printf( "your input %c\n" , seq[i]);
    
                        if(seq[i] == '0')
                        {
                            total_chars = i;
                            break;
                        }
    
                    }
    
    
                    for(z=0 ; z<13 ; z++ )
                    {
    
                        for (i=0; i<13; i++)
                        {
                            if (seq[z]==Table[i])
                                //tmp[z]=i;
    
                                printf("\n%d" ,i);   // here i get a sequence of numbers the question is how can i copy this  sequence to an array and the print the array out ?
    
    
    
                        }
    
    
                    }
    
                    return 0;
                }
    Last edited by Dr Shuti; 10-12-2013 at 04:15 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to duplicating the Array & copy tokenPtr to an array
    By Watervase Chew in forum C Programming
    Replies: 21
    Last Post: 04-22-2013, 08:35 AM
  2. why can't a static array copy values from a dynamic array
    By c++noob145 in forum C++ Programming
    Replies: 2
    Last Post: 03-13-2013, 10:25 AM
  3. Replies: 8
    Last Post: 04-04-2012, 09:03 PM
  4. Replies: 2
    Last Post: 03-20-2012, 08:41 AM
  5. Replies: 7
    Last Post: 05-11-2008, 10:57 AM

Tags for this Thread