Hay guys Could u correct that for me .? C

0 Joseph El · December 8, 2015

#include <stdio.h>
#include <stdlib.h>
int main() 

int i; 
char car; 
char ph[100]; 
i=1; 
do { 
printf("Write a character :\n"); 
scanf("%c", &car); 
if(car=='0') 
car=' '; 
ph = car; 
i+=1; 
} while(car!='.'); 
printf("the finale result is : %s", ph); 
system("pause"); 
return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
+2 Dan P · December 8, 2015

#include <stdio.h>
#include <stdlib.h>
int main()
{
int i = 0;
char car;
char ph[100];

do {
printf("Write a character :\n");
scanf("%c", &car);
if(car == '0' && i < 100)
{
car = ' ';
}

ph[i++] = car;
} while(car != '.');

ph[i++] = '\0';

printf("the finale result is : %s", ph);
system("pause");
return 0;
}


That's probably nearer to what you want, although, I haven't tried it.

Dan
  • 1

C

106,972 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator