Author |
Message |
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Wed Feb 21, 2007 10:16 pm Post subject: |
|
|
|
|
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 |
|
|
SamHughes Server Help Squatter
Joined: Jun 30 2004 Posts: 251 Location: Greenwich Offline
|
Posted: Thu Feb 22, 2007 10:51 am Post subject: |
|
|
|
|
And unkown should be unknown. |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Feb 22, 2007 4:46 pm Post subject: |
|
|
|
|
I'm not really sure why it's giving that specific error, but void definition2(char definition[100]) | should be 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 |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Thu Feb 22, 2007 6:22 pm Post subject: |
|
|
|
|
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 |
|
|
Mine GO BOOM Hunch Hunch What What
Age:40 Gender: Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
Posted: Thu Feb 22, 2007 7:06 pm Post subject: |
|
|
|
|
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 |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Thu Feb 22, 2007 7:31 pm Post subject: |
|
|
|
|
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 |
|
|
unknown1988 Guest
Offline
|
Posted: Tue Apr 17, 2007 9:32 pm Post subject: |
|
|
|
|
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
Age:40 Gender: Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
Posted: Wed Apr 18, 2007 3:37 am Post subject: |
|
|
|
|
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.
#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;
} |
&str: 0012FF6C [0012FF6C] str: john jones
&str: 0012FF1C [0012FF6C] str: bob smith
&str: 0012FF6C [0012FF6C] str: bob smith |
|
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Fri May 04, 2007 3:23 pm Post subject: |
|
|
|
|
how would you declare a function like that in C#? what is the name of a function in c#? gracias. |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Fri May 04, 2007 3:38 pm Post subject: |
|
|
|
|
this is the function i have made:
void definitions(string spanish, string english)
{
if (textbox.Text = "aprender");
{
labeldef.Text = " aprender means to learn";
} |
which will be declared here:
void ButtonClick(object sender, EventArgs e)
{
labeltitle.Text = textbox.Text;
toolStripStatusLabel.Text = "Finding Definition...";
void definitions(aprender, english); |
|
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sat May 05, 2007 1:34 am Post subject: |
|
|
|
|
Quote: | 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
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'.
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.
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.
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 |
|
|
|