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 Previous  1, 2
 
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
Bak
?ls -s
0 in


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

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

get rid of the semicolons after your if statements

get rid of the returns... one return per function

"That word is unkown or spelled incorrectly, should be "That word is unkown or spelled incorrectly, "

""to"" should be \"to\"

"""to learn""" should be "\"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
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Thu Feb 22, 2007 10:51 am    Post subject: Reply to topic Reply with quote

And unkown should be unknown.
Back to top
View users profile Send private message Add User to Ignore List
tcsoccerman
Server Help Squatter


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

PostPosted: Thu Feb 22, 2007 3:27 pm    Post subject: Reply to topic Reply with quote

And Bak should stay Bak and answer one last question icon_smile.gif. It says "Missing Terminating " Character" when i compile, here's the code:
Code: Show/Hide
void definition2(char definition[100])
{
   printf("Definition:%s\n", definition);
}

i do terminate with a "..?
i think it's correct. maybe i'm doing something wrong, who know's.
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 22, 2007 4:46 pm    Post subject: Reply to topic Reply with quote

I'm not really sure why it's giving that specific error, but
Code: Show/Hide
void definition2(char definition[100])
should be
Code: Show/Hide
void definition2(char *definition)
, as you're not declaring an array here (and therefore you shouldn't specify the size).

You still need to read a good tutorial, you still don't have a good understanding of functions or arrays.
_________________
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 22, 2007 5:39 pm    Post subject: Reply to topic Reply with quote

I think his way should work too, cyan.

Anyways the problem isn't in that code tsoccerman. This program compiles fine for me:

Code: Show/Hide

#include <stdio.h>

void definition2(char definition[100])
{
   printf("Definition:%s\n", definition);
}

int main()
{
   definition2("apple");

   return 0;
}


Let's see the rest of your code.
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 22, 2007 6:22 pm    Post subject: Reply to topic Reply with quote

First, what compiler do you use, msvc? i use dev c++

Edit: that's odd, when i add more text, it's still only line 19, the error isn't that for original problem on line 19 but there's a "new" problem at line 19, different text. probably a bug in compiler and debugger. where can i get a better one like msvc?
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: Thu Feb 22, 2007 7:06 pm    Post subject: Reply to topic Reply with quote

tcsoccerman wrote:
probably a bug in compiler and debugger. where can i get a better one like msvc?

I really doubt it is a compiler/debugger bug. Attach your whole source code, and we can look for your syntax errors.
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: Thu Feb 22, 2007 7:31 pm    Post subject: Reply to topic Reply with quote

Ok, i guess there's not really anything worthstealing.

Edit: probelm fixed, passed by Bak's (i believe) word is spelled inclrreclty advise. Make's sense. sorry guys. i wonder why it said it about 30 lines back though. hmm
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
unknown1988
Guest


Offline

PostPosted: Tue Apr 17, 2007 9:32 pm    Post subject: Reply to topic Reply with quote

If you can, learn C well, then move to C++. It is much easier to learn that way. If you wrote this same program in C++, you would be doing different things like passing by reference rather then by value which is very ugly. Even in C you should pass a pointer. Passing by a pointer is only putting 4 bytes on the stack rather than, in this case, an array with many elements (by value).
Back to top
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 Apr 18, 2007 3:37 am    Post subject: Reply to topic Reply with quote

unknown1988 wrote:
If you can, learn C well, then move to C++. It is much easier to learn that way. If you wrote this same program in C++, you would be doing different things like passing by reference rather then by value which is very ugly. Even in C you should pass a pointer. Passing by a pointer is only putting 4 bytes on the stack rather than, in this case, an array with many elements (by value).

You have a bit more to learn about C. Even if the function is defined as func(char str[500]), you still pass by reference, not by value. Don't believe me? Give this little script a try. And passing by reference is ugly? I fail to see how.
Code: Show/Hide
#include <stdio.h>
#include <string.h>

void test(char str[20])
{
   strcpy(str, "bob smith");
   printf("&str: %p [%p]   str: %s\n", &str, str, str);
}

int main()
{
   char str[20];

   strcpy(str, "john jones");
   printf("&str: %p [%p]   str: %s\n", &str, str, str);
   
   test(str);
   
   printf("&str: %p [%p]   str: %s\n", &str, str, str);

   return 0;
}

Code: Show/Hide
&str: 0012FF6C [0012FF6C]   str: john jones
&str: 0012FF1C [0012FF6C]   str: bob smith
&str: 0012FF6C [0012FF6C]   str: bob smith
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: Fri May 04, 2007 3:23 pm    Post subject: Reply to topic Reply with quote

how would you declare a function like that in C#? what is the name of a function in c#? gracias.
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: Fri May 04, 2007 3:38 pm    Post subject: Reply to topic Reply with quote

this is the function i have made:

Code: Show/Hide
void definitions(string spanish, string english)
      {
         if (textbox.Text = "aprender");
         {
            labeldef.Text = " aprender means to learn";
         }


which will be declared here:

Code: Show/Hide
void ButtonClick(object sender, EventArgs e)
      {
         labeltitle.Text = textbox.Text;
         toolStripStatusLabel.Text = "Finding Definition...";
         void definitions(aprender, english);
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat May 05, 2007 1:34 am    Post subject: Reply to topic Reply with quote

Quote:
Code: Show/Hide
void definitions(string spanish, string english)
      {
         if (textbox.Text = "aprender");
         {
            labeldef.Text = " aprender means to learn";
         }

first of, don't put semicolons after an 'if' statement. Statements that start a new block with { brackets } usually won't need a semicolon, same goes for 'for' and 'while' statements
Code: Show/Hide
if (condition)
{
}
else
{
}
for(int i = 0; i < n ; i++)
{
}
while (condition)
{
}


Also, don't confuse '=' and '=='
'=' assigns a value, and '==' compares two values.
Using '=' will also return a value, but it returns the value that was assigned... or something like that... might depend on data type. But it will not return 'true' or 'false'.

Code: Show/Hide
void definitions(string spanish, string english)
      {
         if (textbox.Text == "aprender")
         {
            labeldef.Text = " aprender means to learn";
         }



also, unlike C, you don't have to add definitions for every method or functions in C#. The compiler will consider the header of the method when you define it as the declaration.
Code: Show/Hide
void ButtonClick(object sender, EventArgs e)
      {
         labeltitle.Text = textbox.Text;
         toolStripStatusLabel.Text = "Finding Definition...";
         void definitions(aprender, english);

So here, you don't 'declare' your 'definitions()' method, you just need to call it. Which means you don't need to have any type in front of it.
Code: Show/Hide
void ButtonClick(object sender, EventArgs e)
      {
         labeltitle.Text = textbox.Text;
         toolStripStatusLabel.Text = "Finding Definition...";
         definitions(aprender, english);

_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
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 Previous  1, 2
Page 2 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: 631 page(s) served in previous 5 minutes.

phpBB Created this page in 0.544587 seconds : 38 queries executed (80.9%): GZIP compression disabled