Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
c switch problem
Goto page 1, 2  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  [PHP] User Authentication Methods Post :: Post Windows programming "commands&quo...  View next topic  
Author Message
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Thu Feb 15, 2007 5:11 pm    Post subject: c switch problem Reply to topic Reply with quote

I'm trying to do a switch statement when you enter a name and then it gives you a definition. here's my coding for it.

Code: Show/Hide
verb()
    {
      char verb[20];
      const char aprender[8];
      int here;
      printf("Now type the verb:\n");
      scanf("%s",&verb);
      switch(verb[20])
      {
          case aprender[8]:
      {
      printf("Aprender means to learn/understand\n");
      }
      return here;


it's obviously a spanish translator. when i compile it (using dev c++) it says "case label does not reduce to an int constant".
does this mean a case statement needs to be for an int, and can't be for a char[]? i also have a problem with the return statement sometimes. can someone tell me another word besides the return statement because i know this isn't the right way to do it. i'vetried to find a answer but this seems to be the best way for now since the continuum community is filled with coders. ty in advance.

p.s. cyan fire~: i know c++ is better for you, i'm learning c to get started.
p.s.s let me know if you want the entire .c file
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Thu Feb 15, 2007 5:25 pm    Post subject: Reply to topic Reply with quote

yeah switches have to be ints..

try using

if (strcmp(verb,"aprender") == 0)
printf("to learn");
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Thu Feb 15, 2007 6:00 pm    Post subject: Reply to topic Reply with quote

ty for reply, i did what you said before i looked at reply but did this instead:


Code: Show/Hide


if ( strcmp (language[10], "english") =="%c means %c",english spanish;




i'll try out what you said. ty
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Thu Feb 15, 2007 6:06 pm    Post subject: Reply to topic Reply with quote

Also, if you have for example:

printf("%d = %d", english spanish);

is taht how you would declare waht integer %d is printing. if not could you plz tell me. ty.

Edit: ok, this is so screwd up, here's my code. i need it more clean i don't think the things i'm doing are correct. ty.

Code: Show/Hide

definition(char language[10], char english[25], char spanish[25])
{
       
       while
       {
                (strcmp(language,"english") == 0);
                }   
       printf("%s = %s", english[25], spanish[25]);
           while
           {
            (strcmp (language, "spanish") ==0);
            }
       printf("%c means %c", spanish[25], english[25]);
       }
       return verb();       

ty for any help. it just seems screwy.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Thu Feb 15, 2007 6:40 pm    Post subject: Reply to topic Reply with quote

OK, I'm not trying to be mean here, but there's no point in me explaining the entire language to you. C++ Tutorial. I'm glad you're using printf(), continue to do so even though the tutorial uses cin/cout.

You seem to have an understanding of the very basics, so I'd suggest starting with "Control Structures"
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Thu Feb 15, 2007 7:05 pm    Post subject: Reply to topic Reply with quote

Code: Show/Hide

void definition(char language[10], char english[25], char spanish[25])
{
       
       if (strcmp(language,"english") == 0)   
       {
              printf("%s = %s", english, spanish);
       }       
       else
       {     
              printf("%s means %s", spanish, english);
       }
}
Back to top
View users profile Send private message Add User to Ignore List AIM Address
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Thu Feb 15, 2007 7:51 pm    Post subject: Reply to topic Reply with quote

Question:why are you glad i'm using printf()? are you just respecting my opinion on c? if so ty. That tutorial was somewhat likehttp://www.cprogramming.com/tutorial.html#ctutorial except they teach different things in different orders. kinda not liking switching over to that ""tutorial" plainly because of it's different order. It could be the other way areound if i started with you're site.

Edit: i looked for the answer at you're site but couldn't find it:

Q:If you have declared a function with arguements including character's that have more than 1 elements and therefore have a [25] after them, what do you do when you use the funcion? do you include the [25] after the word you're replacing the char for? here's my coding:

Code: Show/Hide
char definition(char language[10], char english[25], char spanish[25])
{
       
       if (strcmp(language,"english") == 0)   
       {
              printf("%s = %s", english, spanish);
       }       
       else
       {     
              printf("%s means %s", spanish, english);
       }
}


which is for the function, now i'm calling the function up:

Code: Show/Hide

char definition(english[10], learn[25], aprender[25]);


it shouldn't be too hard of a question. btw c++ looks a lot more easier and efficient! wow.ty in advance i hope. last question for a while. i promise
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Feb 16, 2007 3:09 am    Post subject: Reply to topic Reply with quote

when you do things like
Code: Show/Hide
variable_type variable_name[size];


you're not just making a single variable, you're making a whole bunch of them. So in the example I gave, you will get <size> different variables of type <variable_type>(int, or char, for example).

In your example you're using entire words which are in reality just a bunch of characters. So "char language[10]" means a group of ten variables of type "char".

you use the []'s to refer to the individual characters in regular code (not in the function declaration), use just the variable name usually when you want to refer to the whole word. That's probably enough detail for now, there's actually a good reason for all of this, which you'll learn later if you keep coding.

Try to figure out what the following code will print, then run it:
Code: Show/Hide

char string[10] = "english";

printf("string is '%s', string[1] is '%c', string[2] is '%c'\n",
               string, string[1], string[2]);
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Fri Feb 16, 2007 5:33 am    Post subject: Reply to topic Reply with quote

Code: Show/Hide
char definition(char language[10], char english[25], char spanish[25])
{
...
}
You're not returning anything, so "char definition(...)" should be "void definition(...)".

To call the function you can use something like:
Code: Show/Hide
definition("english", "learn", "aprender");

_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Feb 16, 2007 7:57 am    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
I'm glad you're using printf(), continue to do so even though the tutorial uses cin/cout.


Cyan, printf() is less efficient (which, if I recall, is your primary gripe with Java), and it also doesn't do type checking. There's a reason every C++ tutorial uses it, and it's not because they've never heard of printf().
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Feb 16, 2007 10:24 am    Post subject: Reply to topic Reply with quote

tcsoccerman, I suggested that tutorial because I was under the impression that you weren't using a tutorial and just trying to put together code from what you'd seen in MERVBot or something. Sure, stick with whatever tutorial you're using, but you do (did, I guess, if you got what BaK said) need to relearn how functions work, so start there.


Brain,
Code: Show/Hide
/*
        Func          Func+Child           Hit
        Time   %         Time      %      Count  Function
---------------------------------------------------------
       0.290  48.2        0.290  48.2       10 complex_output(void) (etest.obj)
       0.224  37.1        0.224  37.1       10 just_a_string_printf(void) (etest.obj)
       0.081  13.4        0.081  13.4       10 just_a_string_puts(void) (etest.obj)
       0.008   1.3        0.603 100.0        1 _main (etest.obj)
      */

#include <stdio.h>

void just_a_string_printf()
{
   printf("using printf\n");
}

void just_a_string_puts()
{
   puts("using puts   ");
}

void complex_output()
{
   printf("%s is the %d-best game in the world\n", "Continuum", 21);
}

int main()
{
   int i;

   i = 10;
   while (i--)
      just_a_string_printf();

   i = 10;
   while (i--)
      just_a_string_puts();

   i = 10;
   while (i--)
      complex_output();

   return 0;
}

Code: Show/Hide
/*
        Func          Func+Child           Hit
        Time   %         Time      %      Count  Function
---------------------------------------------------------
       2.741  75.8        2.741  75.8       10 complex_output(void) (etest_cout.obj)
       0.873  24.1        0.873  24.1       10 just_a_string(void) (etest_cout.obj)
       0.003   0.1        0.004   0.1        1 _$E25 (etest_cout.obj)
       0.001   0.0        0.001   0.0        1 _$E22 (etest_cout.obj)
       0.000   0.0        0.000   0.0        1 _$E28 (etest_cout.obj)
       0.000   0.0        0.000   0.0        1 _$E23 (etest_cout.obj)
       0.000   0.0        0.000   0.0        1 _$E24 (etest_cout.obj)
       0.000   0.0        0.000   0.0        1 _$E29 (etest_cout.obj)
       0.000   0.0        0.000   0.0        1 _$E30 (etest_cout.obj)
       0.000   0.0        0.000   0.0        1 _$E31 (etest_cout.obj)
       0.000   0.0        3.614  99.9        1 _main (etest_cout.obj)
*/

#include <iostream>

using namespace std;

void just_a_string()
{
   cout << "using cout\n";
}

void complex_output()
{
   cout << "Continuum" << " is the " << 21 << "-best game in the world\n";
}

int main()
{
   int i;

   i = 10;
   while (i--)
      just_a_string();

   i = 10;
   while (i--)
      complex_output();

   return 0;
}

So complex_output() using printf() was actually faster than just_a_string() using cout so you can't even argue that cout is better in certain cases.

I guess it's possible that VC6 has a crappy version of the STL, but it's definitely not faster for me at least. By the way, these are compiled using MSVCRT.dll instead of static linking because I couldn't get the second file to compile for some reason (seems to be an issue with the new /GS switch that VC6 doesn't support... I don't really know).
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Feb 16, 2007 12:51 pm    Post subject: Reply to topic Reply with quote

honestly, how much printing do your programs do? console output isn't the bottleneck in any resonable program; optimize where it matters.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Feb 16, 2007 1:28 pm    Post subject: Reply to topic Reply with quote

Cyan, I've already tested the speed differences: http://forums.minegoboom.com/viewtopic.php?p=59625#59625

I assume you didn't compile in release mode when you timed everything.

Cyan, you may find this link amusing: http://forums.minegoboom.com/viewtopic.php?p=28316#28316

Bak, of course it doesn't matter how fast it is. I just get tired of hearing people say that efficiency is the greatest thing in the world and promoting printf at the same time. I have nothing against printf, just the zealots that hate iostream.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Feb 16, 2007 3:16 pm    Post subject: Reply to topic Reply with quote

Brain wrote:
Cyan, I've already tested the speed differences: http://forums.minegoboom.com/viewtopic.php?p=59625#59625

Ahh right, I had forgotten about that. I'll have to try your source files once I get home, too.

Brain wrote:
I assume you didn't compile in release mode when you timed everything.

I did.

Brain wrote:
Cyan, you may find this link amusing: http://forums.minegoboom.com/viewtopic.php?p=28316#28316

I hope you'll notice I'm not putting down printf() there, I was actually just using Ekted's printf() dogma to point out his hypocrisy. I do not consider myself a prinf "zealot" (or at least not on Ekted's level), I simply made a comment here that I'm happy that tcsoccerman is using it. And you start arguing. Who's the zealot?

More related, there are two possible explanations for the differences between our tests. A possibly crappy version of STL in VC6, which I mentioned earlier, or that STL handles integers better, but strings worse. Your test programs only outputted integers, mine did a string and an integer. I'll have to play with it later.

BaK wrote:
honestly, how much printing do your programs do? console output isn't the bottleneck in any resonable program; optimize where it matters.

Definitely agreed. Even if Brain could prove to me that iostreams are faster than stdio in every single case, I'd still use stdio because I prefer the interface.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sun Feb 18, 2007 3:34 pm    Post subject: Reply to topic Reply with quote

I prefer printf because it's easier for me to do formatting with it, and that's about it.
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Sun Feb 18, 2007 9:53 pm    Post subject: Reply to topic Reply with quote

I only prefer printf() when it comes to really complex formatting. Well, basically, I just hate iomanip, and would use printf() to avoid using anything held in iomanip. It probably annoys my professors, but they've yet to dock me any points for it, it's not like I can't do it in iostream. Besides, I doubt it's really going to hurt me in the future if I never learn std::setiosflags.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Feb 19, 2007 12:23 am    Post subject: Reply to topic Reply with quote

Animate wrote:
Besides, I doubt it's really going to hurt me in the future if I never learn std::setiosflags.

It might. Learning the STL is definitely a good idea in today's world, you never know when you'll be forced to use it.

By the way, I got the following timings for Brain's files:
Code: Show/Hide
/*

        Func          Func+Child           Hit
        Time   %         Time      %      Count  Function
---------------------------------------------------------
    1915.341 100.0     1915.341 100.0        1 _main (brain_iostream.obj)
       0.002   0.0        0.003   0.0        1 _$E25 (brain_iostream.obj)
       0.001   0.0        0.001   0.0        1 _$E22 (brain_iostream.obj)
       0.000   0.0        0.000   0.0        1 _$E23 (brain_iostream.obj)
       0.000   0.0        0.000   0.0        1 _$E28 (brain_iostream.obj)
       0.000   0.0        0.000   0.0        1 _$E29 (brain_iostream.obj)
       0.000   0.0        0.000   0.0        1 _$E24 (brain_iostream.obj)
       0.000   0.0        0.000   0.0        1 _$E30 (brain_iostream.obj)
       0.000   0.0        0.000   0.0        1 _$E31 (brain_iostream.obj)

*/
/*
        Func          Func+Child           Hit
        Time   %         Time      %      Count  Function
---------------------------------------------------------
     914.573 100.0      914.573 100.0        1 _main (brain_printf.obj)
    */

Who knows? The only explanation I can think of is our libraries, so I guess that's it. Anyway, the time difference is so tiny that it, as has been mentioned, is really just a personal choice. Actually, what we should do is file I/O because that's where I noticed a real speed difference in a real-world application instead of these synthetic stuff.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Mon Feb 19, 2007 6:49 pm    Post subject: Reply to topic Reply with quote

Wow. what a nice discussion to come home too. I'll compile my program and see if it works.

@cyanfire:
functions to "start" with. I do understand functions and the basics of what they do, just not polished in that area.

@bak:

i know what that would say lol. i understand char's quite well. it would say "english e n". or is the stupid starting at 0 rule in affect? then it would say "english n g". anyway thanks for help anyways. i hope it works.


edit - worked icon_wink.gif
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Tue Feb 20, 2007 5:09 pm    Post subject: Reply to topic Reply with quote

this is awkward. take a look at the codeing:

Code: Show/Hide
printf("Now type the verb:\n");
      scanf("%s",&verb);
      if (strcmp (verb, "aprender"))
         {
         definition("english", "learn", "aprender");
         }
      else (strcmp (verb, "beber"))
         {
         definition("english", "beber", "drink");
         }
      else if (strcmp (verb, "comer"))
         {   
         definition("english", "comer", "eat");
         }
     


the definition() function:

Code: Show/Hide
void definition(char language[10], char english[25], char spanish[25])
{
       
       if (strcmp(language,"english") == 0)   
       {
              printf("%s = %s\n", english, spanish);
       }       
       else
       {     
              printf("%s means %s\n", spanish, english);
       }

       return verb();       



and display:

Code: Show/Hide
Welcome to Scott's Beginner level translater, what
subject would you like to work on?
1.verbs
2.nouns
3.greetings
4.rules
5.Entire library
1
|==================================================|
|Form   Ar Verbs    Er verbs    Ir verbs   Example=|
|==================================================|
|Yo--------o-----------o----------o--------hablo---|
|Tu--------as----------es---------es-------halblas-|
|El--------a-----------e----------e--------escribe-|
|Ud.-------a-----------e----------e--------aprenede|
|Ella------a-----------e----------e--------bebe----|
|Uds.------an----------en---------en-------aprenden|
|Ellos-----an----------en---------en-------comen---|
|Ellas-----an----------en---------en-------leen----|
|Nosotros--amos--------emos-------imos-----leimos--|
|Nosotras--amos--------emos-------imos-----bebimos-|
|==================================================|
You've chose verbs. type a word and it
will translate for you
Now type the verb:
aprender         right here these two lines are awkward
beber = drink      and here these two lines are awkward
Now type the verb:
learn
learn = aprender
Now type the verb:




isn't that awkward. is there a way to do this:
Code: Show/Hide
if (strcmp (verb, "aprender"))==[b]1[/b]


and then take the 1 and have it in a switch statement like this:
Code: Show/Hide
switch(verb)
case [b]1[/b]:
{
printf("aprender means to learn\n");
}

it annoys me you can't do switch statements with char's

new_let_it_all_out.gif new_let_it_all_out.gif new_let_it_all_out.gif new_let_it_all_out.gif new_let_it_all_out.gif new_let_it_all_out.gif new_let_it_all_out.gif new_let_it_all_out.gif new_let_it_all_out.gif new_let_it_all_out.gif

anyway, it be nice if you could help in telling me a way to do a char. switch statement thing. ty.

p.s. to those who think i am posting too much, i agree. there are so many good coder's here though and everywhere i tried i couldn't find a solution(on the internet at least, don't have a book)
ty again.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Feb 20, 2007 8:05 pm    Post subject: Reply to topic Reply with quote

tcsoccerman wrote:
it annoys me you can't do switch statements with char's

I'll assume you mean switch statements on char arrays. This was never part of C because switch statements are not directly the same as a bunch of if/else statements. Most compilers will optimize a switch statement into a small batch of jumps or a table lookup, which is complex to handle unless the data is an integer.

strcmp returns 0, less than 0, or greater than 0. You cannot assume that it will only return 0, -1, or 1, so you should not use the return of strcmp in a switch statement.

If you want to do a bunch of strcmp tests, a simple way is to just use a bunch of if statements.
Code: Show/Hide
if (!strcmp(input, "english"))
   printf("You inputed English.");
else if (!strcmp(input, "spanish"))
   printf("I'm sorry, I forgot Spanish a bunch of years back. Que pasa?");
else if (!strcmp(input, "backdoor"))
   printf("Welcome master, how many I do your bidding?");
else
   printf("ERROR 0x0000072");

Remember, strcmp returns 0 if it is a match. Your example code is all screwed up. Use ! or == 0.
Back to top
View users profile Send private message Add User to Ignore List Send email
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Wed Feb 21, 2007 6:35 am    Post subject: Reply to topic Reply with quote

careful, you have to put your parameters in the right order:

Code: Show/Hide
definition("english", "beber", "drink");

Code: Show/Hide
definition("english", "comer", "eat");


"drink and "eat" should be before "beber" and "comer"
Back to top
View users profile Send private message Add User to Ignore List AIM Address
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Wed Feb 21, 2007 3:21 pm    Post subject: Reply to topic Reply with quote

ty. MGB hit the answer right on the button though. The tutorial example's only show 1 "else if" so it doesn't seem as if they can be used many times like i needed to. I'll keep this in mind to tell if i ever help someone as well.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Wed Feb 21, 2007 3:57 pm    Post subject: Reply to topic Reply with quote

Parse Error before parse error?:

Code: Show/Hide
if (strcmp (verb, "aprender"));
         {
         definition("english", "learn", "aprender");
         return here;
         }
      else if (strcmp (verb, "beber"));
         {
         definition("english", "beber", "drink");
         return here;
         }
      else if (strcmp (verb, "comer"));
         {   
         definition("english", "comer", "eat");
         return here;
         }
      else printf("That word is unkown or spelled incorrectly,
      "remember to put a ""to"" in front of the word such as"
      """to learn""");
     


ty again.
~the stupidist coder in the world
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Wed Feb 21, 2007 4:02 pm    Post subject: Reply to topic Reply with quote

tcsoccerman wrote:
MGB hit the answer right on the button though.

strcmp returns 0 if the strings match. If is only true if the value is not 0. Your if statements are still incorrect.

You need if (strcmp(verb, "aprender") == 0) or if (!strcmp(verb, "aprender")) for the statement to be true when the strings are the same. Notice the ! in the second example, or any of my else-if examples.
Back to top
View users profile Send private message Add User to Ignore List Send email
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Wed Feb 21, 2007 7:58 pm    Post subject: Reply to topic Reply with quote

yes i noticed that. i interperted that though as the following and didn't seem it would be right to use it.

"if verb is not "aprender"
statement;

what does it actually mean? ty. by "returning 0" does that quit the program then? i'd look that up online but my dad's bugging me to get off. ty.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 644 page(s) served in previous 5 minutes.

phpBB Created this page in 0.667809 seconds : 51 queries executed (78.0%): GZIP compression disabled