why my case give me the errors?Why i can't put variables in switch cases?

Alex Sturza

I have 2 errors while trying to put a variable in switch case:

#include <stdio.h>
int main(int argc, char *argv[]) {
  float conversie = 0;
  float leu = 1;
  float usd = 3.6 * leu;
  float eur = 4.4 * leu;
  float aur = 139 * leu;
  float suma;
  float valoare;
  char tipmoneda;
  printf("introdu moneda pe care vrei sa o schimbi:");
  scanf("%c\n", &tipmoneda);
  switch (tipmoneda) {
  case 'usd':

  default:
    break;
  }

}

These are the errors:

Untitled.c:14:8: warning: multi-character character constant [-Wmultichar] case 'usd': ^
Untitled.c:14:8: warning: overflow converting case value to switch condition type (7697252 to 100) [-Wswitch]
2 warnings generated.
srsci

C switch case only works with integer or single character types.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

I can't put my Login Form in the correct place

분류에서Dev

Why can't I switch to a virtual avfs directory with quotes?

분류에서Dev

I can't call variables from my other page PHP

분류에서Dev

Why can't I crash my system with a fork bomb?

분류에서Dev

Why can't I spoof Facebook with my own DNS server?

분류에서Dev

Why can't I restart my maia service?

분류에서Dev

Why can't I create a new Thread with an instance of my class?

분류에서Dev

Why can't I compile USB Proxy on my Beaglebone?

분류에서Dev

Why can't I access my objects member variable?

분류에서Dev

Why doesn't grep give me the all found strings?

분류에서Dev

How can I give an imported library access to current global variables?

분류에서Dev

Why is my JMockit test case not failing when I don't provide the correct expectations on a Strict Expectation?

분류에서Dev

Why switch case in javascript doesn't work with string on Microsoft Edge?

분류에서Dev

Why my jdk can't work,and before the java_home, there is a space that is not from me

분류에서Dev

Why can't I convert DynamicJson to my class if I don't write {get; set;}

분류에서Dev

Is there any way I can give my app an icon?

분류에서Dev

Why can't I log in to my Samba share on my home network?

분류에서Dev

Where to put my functions so that it can be called from my switch statement?

분류에서Dev

Why is my javascript function not being invoked for simple MVC tutorial? Why can't I debug either?

분류에서Dev

Why does updating Oh My Zsh give me an error about rebasing with unstaged changes?

분류에서Dev

How can I simplify my "equation" to switch between 3 and 5?

분류에서Dev

I already have a switch case statement in my reducer. How do I add an extra if condition in reducer?

분류에서Dev

How many pictures can i put in my app?

분류에서Dev

Can anyone tell me why my program crashes when I try to call the Insert or Delete function in a menu driven array manipulation program?

분류에서Dev

Why can't I copy a large number of files to my USB flash drive?

분류에서Dev

Why can't I set a static IP address for my Linux box?

분류에서Dev

Why can't I add the newtonsoft.Json.dll ref to my project?

분류에서Dev

why i can't import my grid view with custom adapter into a fragment?

분류에서Dev

Why can't I create a partition table on my USB flash drive using GParted?

Related 관련 기사

  1. 1

    I can't put my Login Form in the correct place

  2. 2

    Why can't I switch to a virtual avfs directory with quotes?

  3. 3

    I can't call variables from my other page PHP

  4. 4

    Why can't I crash my system with a fork bomb?

  5. 5

    Why can't I spoof Facebook with my own DNS server?

  6. 6

    Why can't I restart my maia service?

  7. 7

    Why can't I create a new Thread with an instance of my class?

  8. 8

    Why can't I compile USB Proxy on my Beaglebone?

  9. 9

    Why can't I access my objects member variable?

  10. 10

    Why doesn't grep give me the all found strings?

  11. 11

    How can I give an imported library access to current global variables?

  12. 12

    Why is my JMockit test case not failing when I don't provide the correct expectations on a Strict Expectation?

  13. 13

    Why switch case in javascript doesn't work with string on Microsoft Edge?

  14. 14

    Why my jdk can't work,and before the java_home, there is a space that is not from me

  15. 15

    Why can't I convert DynamicJson to my class if I don't write {get; set;}

  16. 16

    Is there any way I can give my app an icon?

  17. 17

    Why can't I log in to my Samba share on my home network?

  18. 18

    Where to put my functions so that it can be called from my switch statement?

  19. 19

    Why is my javascript function not being invoked for simple MVC tutorial? Why can't I debug either?

  20. 20

    Why does updating Oh My Zsh give me an error about rebasing with unstaged changes?

  21. 21

    How can I simplify my "equation" to switch between 3 and 5?

  22. 22

    I already have a switch case statement in my reducer. How do I add an extra if condition in reducer?

  23. 23

    How many pictures can i put in my app?

  24. 24

    Can anyone tell me why my program crashes when I try to call the Insert or Delete function in a menu driven array manipulation program?

  25. 25

    Why can't I copy a large number of files to my USB flash drive?

  26. 26

    Why can't I set a static IP address for my Linux box?

  27. 27

    Why can't I add the newtonsoft.Json.dll ref to my project?

  28. 28

    why i can't import my grid view with custom adapter into a fragment?

  29. 29

    Why can't I create a partition table on my USB flash drive using GParted?

뜨겁다태그

보관