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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
C

cstudent1

@cstudent1
About
Posts
7
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Multiple functions
    C cstudent1

    I am trying what you suggested and now I get the errors countChar can not be used as a function and, invalid types of int for array. I am really lost.

    C# help tutorial

  • Multiple functions
    C cstudent1

    This is supposed to be c code, I used my C book as the base of the code.Thanks for the tips. Can you help me with the counting? I think the problem I am running into is that I used i once for example when counting vowels and can not use it again when counting words. I'm really stuck here.

    C# help tutorial

  • Multiple functions
    C cstudent1

    Hi, I am hoping someone can help me with this. I need a program that counts char,vowels and words. I can get it to do all those things alone, but I am at a loss on how to make it all work together. Please help. Thanks! This is the program to count char, it works fine..... #include #include #define MAXNUM 1000 int countchar(char[]); int main() { char message [MAXNUM]; int numchar; printf("\nType in any number of characters : "); gets(message); numchar = countchar(message); printf("\nThe number of characters is %d",numchar); return 0; } int countchar(char list []) { int i, count = 0; for(i=0; list[i] != '\0'; i++) count++; return(count); } This is the program to count vowels, it worked fine until i tried to add the char count..... #include int main() { char str, line[150]; int i,v,c,ch,d,s,o,l, countchar, count, list; o=v=c=ch=l=d=s=0; printf("Enter a line of string:\n"); gets(line); for(i=0;line[i]!='\0';++i) { if(line[i]=='a' || line[i]=='e' || line[i]=='i' || line[i]=='o' || line[i]=='u' || line[i]=='A' || line[i]=='E' || line[i]=='I' || line[i]=='O' || line[i]=='U') ++v; } { int countchar(char list []) int i, count = 0; for(i=0; list[i] != '\0'; i++) count++; return(count); } printf("Vowels: %d",v); printf("characters %d",countchar); return 0; }

    C# help tutorial

  • if/else, expression can not be used as a function. C program
    C cstudent1

    Thank you!!! Removed opselect and it works!

    C / C++ / MFC help question

  • if/else, expression can not be used as a function. C program
    C cstudent1

    This assignment calls for a switch statement, I thought you needed opselect when using a switch? I tired using case:1, case 2 etc..., but I couldn't make it work. How do I do the switch w/o the if statements? Thank you so much for your help.

    C / C++ / MFC help question

  • if/else, expression can not be used as a function. C program
    C cstudent1

    Thanks, I am trying to implement your suggestions here is what I currently have.. #include #define MAXCOUNT 10 int main () { int opselect; int day, month; printf("Enter a month between 1-12 :"); scanf("%d", &month); printf("Enter a number for the day of the month"); scanf("%d", &day); scanf("%d", &opselect); switch (opselect) { case 1: if (month==2 && (day < 1 || > 28)) {printf("\nEnter a day between 1 and 28: \n "); scanf("%d",&day); } case 2: else if (month==4 || month==6 || month==9 || month==11)&&(day < 1 || day > 30)) {printf("\nEnter a day between 1 and 30: \n "); scanf("%d",&day); } case 3: else if (month==3 || month==5 || month==7 || month==10 || month==12)&&(day < 1 || day > 31)) {printf("\nEnter a day between 1 and 31: \n "); scanf("%d",&day); } printf("The day accepted is %d\n",day); return 0; } I am getting a ton of errors here, expected primary-expression before else, expected; before else. What I am trying to do is based on the month input prompt for a the proper number of days in the month(2=28, 1=31 etc)and get in error message if you enter the wrong days(29 in Feb for example)

    C / C++ / MFC help question

  • if/else, expression can not be used as a function. C program
    C cstudent1

    Hi everyone, I am taking my first programming class and am at a loss on this program. Any tips for making this wrk? Thanks! #include int main() { int month,day,opselect; printf("\nEnter a month between 1 and 12: \n "); scanf("%d",&month); while (month < 1 || month > 12) { printf("Error the month entered is not valid.\n"); printf("\nEnter a month between between 1 and 12: "); scanf("%d",&month); } printf("The month accepted is %d\n",month); printf("\nEnter a day between 1 and 31: \n "); scanf("%d",&day); scanf("%d",opselect); switch (opselect) if (month=2) (day < 1 || day > 28); { printf("Error the day entered is not valid.\n"); printf("\nEnter a day between 1 and 28\n"); scanf("%d,&day"); } else (month=4,6,9,11) (day < 1 || day > 30); { printf("Error the day entered is not valid.\n"); printf("\nEnter a day between 1 and 30\n"); scanf("%d,&day"); } return 0; } errors are "else w/o a previous if" and "expression can not be used as a function"

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

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