Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Here is a C Program showing some Error, Give some solution

Here is a C Program showing some Error, Give some solution

Scheduled Pinned Locked Moved ATL / WTL / STL
c++visual-studiohelp
3 Posts 2 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 9654682
    wrote on last edited by
    #1

    #include #include int *val1,*val2; int *oper; void calc(val1,val2,oper) { switch(*oper) { case '+':printf("%d",*val1+*val2); break; case '-':printf("%d",*val1-*val2); break; case '*':printf("%d",*val1 * *val2); break; case '/':printf("%d",*val1 / *val2); break; default:printf("invalied input"); } } void main() { int num1,num2; int oper1; printf("Enter 2 number and an operator\n"); scanf_s("%d%d%d",&num1,&num2,&oper1); //fflush(stdin); calc(&num1,&num2,&oper1); _getch(); } it is showing all of the following ERRORS

    Error 2 error C2017: illegal escape sequence c:\users\lina\desktop\project7\project7\source.cpp 33 1 Project7
    Error 1 error C2448: 'calc' : function-style initializer appears to be a function definition c:\users\lina\desktop\project7\project7\source.cpp 8 1 Project7
    Error 3 error C3861: 'calc': identifier not found c:\users\lina\desktop\project7\project7\source.cpp 33 1 Project7
    6 IntelliSense: variable "oper" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 21 Project7
    4 IntelliSense: variable "val1" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 11 Project7
    5 IntelliSense: variable "val2" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 16 Project7

    L 2 Replies Last reply
    0
    • U User 9654682

      #include #include int *val1,*val2; int *oper; void calc(val1,val2,oper) { switch(*oper) { case '+':printf("%d",*val1+*val2); break; case '-':printf("%d",*val1-*val2); break; case '*':printf("%d",*val1 * *val2); break; case '/':printf("%d",*val1 / *val2); break; default:printf("invalied input"); } } void main() { int num1,num2; int oper1; printf("Enter 2 number and an operator\n"); scanf_s("%d%d%d",&num1,&num2,&oper1); //fflush(stdin); calc(&num1,&num2,&oper1); _getch(); } it is showing all of the following ERRORS

      Error 2 error C2017: illegal escape sequence c:\users\lina\desktop\project7\project7\source.cpp 33 1 Project7
      Error 1 error C2448: 'calc' : function-style initializer appears to be a function definition c:\users\lina\desktop\project7\project7\source.cpp 8 1 Project7
      Error 3 error C3861: 'calc': identifier not found c:\users\lina\desktop\project7\project7\source.cpp 33 1 Project7
      6 IntelliSense: variable "oper" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 21 Project7
      4 IntelliSense: variable "val1" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 11 Project7
      5 IntelliSense: variable "val2" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 16 Project7

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please format the code block properly, and identify line 33.

      Use the best guess

      1 Reply Last reply
      0
      • U User 9654682

        #include #include int *val1,*val2; int *oper; void calc(val1,val2,oper) { switch(*oper) { case '+':printf("%d",*val1+*val2); break; case '-':printf("%d",*val1-*val2); break; case '*':printf("%d",*val1 * *val2); break; case '/':printf("%d",*val1 / *val2); break; default:printf("invalied input"); } } void main() { int num1,num2; int oper1; printf("Enter 2 number and an operator\n"); scanf_s("%d%d%d",&num1,&num2,&oper1); //fflush(stdin); calc(&num1,&num2,&oper1); _getch(); } it is showing all of the following ERRORS

        Error 2 error C2017: illegal escape sequence c:\users\lina\desktop\project7\project7\source.cpp 33 1 Project7
        Error 1 error C2448: 'calc' : function-style initializer appears to be a function definition c:\users\lina\desktop\project7\project7\source.cpp 8 1 Project7
        Error 3 error C3861: 'calc': identifier not found c:\users\lina\desktop\project7\project7\source.cpp 33 1 Project7
        6 IntelliSense: variable "oper" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 21 Project7
        4 IntelliSense: variable "val1" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 11 Project7
        5 IntelliSense: variable "val2" is not a type name c:\Users\Lina\Desktop\Project7\Project7\Source.cpp 7 16 Project7

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Replace

        int *val1,*val2;
        int *oper;

        void calc(val1,val2,oper)

        with

        //int *val1,*val2;
        //int *oper;

        void calc(int* val1,int* val2,int* oper)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups