Thread: I dont know where i did mistake.Help plz

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    72

    I dont know where i did mistake.Help plz

    hi friends;
    program asks to user " FirstName ,Secondname, Surname, IdNumber" the user input the answer for example;"thomas edison carter 123456" there must be one space between every answer.After user press "enter" and the same question comes again,(program asks to user " FirstName ,Secondname, Surname, IdNumber").this time user input different answers for example:
    julia robert ang 132 /*After presses enter*/
    the new question comes.The maximum name surname second name and idnumber digits only can be 6.

    for example i inputed these answers

    Code:
    FirstName ,Secondname, Surname, IdNumber :thomas edison carter 123456
    FirstName ,Secondname, Surname, IdNumber :julia robert ang 132
    FirstName ,Secondname, Surname, IdNumber :shio angela pars 1534
    FirstName ,Secondname, Surname, IdNumber :tommy sabri zahan 53
    FirstName ,Secondname, Surname, IdNumber :smart idea is 3245
    ------------------------------------------

    this question will be answered 5 times. And the computer write all the answers in its memory and after all the questions are answered,
    the program will show them as

    Code:
    thomas edison carter 123456
    julia  robert ang    132   
    shio   angela pars   1534  
    tommy  sabri  zahan  53    
    smart  idea   is     3245

    my problem is this,
    i did all these things but, in the example above but this answer comes to screen

    Code:
    thomas edison carter 12345j
    julia robert 132          s
    shio angela pars 1534     t
    tommy sabri zahan 53      s
    smart ideaais 3245 is 3245


    My wrote code is :



    Code:
    #include <stdio.h>
    int main()
    {
        
        int i,i1,i2,i3,length_dizi,cyclex;
        int spacex=0;
        char dizi[26];
        char matrx[4][26];
    
    
    for (cyclex=0;cyclex<5;cyclex++)
    {
        for(i=0;i<=26;i++)
        {
            matrx[cyclex][i]=' '; /*All matrix is space*/
            dizi[i]=' ';         /*All array is space*/
        }
    
    
        printf("1.Name, 2.Name, Surname, IDnumber :");
        gets(dizi);
    
    
       for(i=0;dizi[i]!='\0';i++) /*number of array*/
       {
         length_dizi=i;
       }
    
    
       spacex=0;
       for(i=0;i<=length_dizi;i++){
        if(dizi[i]==' ') spacex++;
    
    
    
    
    
    
          if((dizi[i]!=' ')&&(spacex==0)&&(i<7))  {matrx[cyclex][i]=dizi[i];}
          if((dizi[i]!=' ')&&(spacex==1)&&(i<14)) {matrx[cyclex][i]=dizi[i];}  
          if((dizi[i]!=' ')&&(spacex==2)&&(i<21)) {matrx[cyclex][i]=dizi[i];}
          if((dizi[i]!=' ')&&(spacex==3)&&(i<27)) {matrx[cyclex][i]=dizi[i];}
    
    
    
    
       }
    }
    for(i=0;i<=4;i++)
    {
       for(i2=0;i2<27;i2++) {printf("%c",matrx[i][i2]);}
    printf("\n");
    }
    getche();
    }
    Last edited by rac1; 11-19-2011 at 10:00 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. mistake of using awk
    By lehe in forum Linux Programming
    Replies: 6
    Last Post: 04-02-2009, 04:41 PM
  2. What is my mistake ?
    By Freelander1983 in forum C++ Programming
    Replies: 10
    Last Post: 12-11-2007, 09:31 AM
  3. if you dont like linux threads, dont read...
    By ... in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 02-03-2003, 11:26 AM