I really have problem with strings. If function wont work and it is printing from else . Why?
char trenutni;
//more code
printf("Unesite polje koje zelite da otvorite!\n");
scanf("%c",&trenutni);
if(trenutni=='a1' && a1otvoreno!=0)
{
strncpy(a1, "koordinate", sizeof(a1));
printf("A1 je %s", a1);
printf("Da li zelite da pogadjate? Unesite slovo kolone, za konacno R ili ako ne zelite upisite 0!\n");
scanf("%c",biranje);
brojodigranih++;
a1otvoreno--;
if(biranje=='A')
{
printf("Unesite resenje za kolonu A:\n");
//more code
else
printf("Vec ste otvorili to polje!\n");
This seems suspicious:
trenutni=='a1'
Typically you should put a single character inside single quotes ''
.
NB: According to the standard : "The value of an integer character constant containing more than one character (eg, 'ab'
), [...] is implementation-defined."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.