we can develope a game by using a c language
Yes, you certainly can.
no it is not solved
What?
we can develope a game by using a c language
Yes, you certainly can.
no it is not solved
What?
And isn't that how structures are declared??
The structure itself is more likely to be declared globally (though they can just as easily be declared within main or another function). The array of structs, maybe... but it's much safer to have that in main or somewhere else and pass it around via function parameters. When you are referring to specific members of a struct like account[0].yada, they have to be placed in one function or another, they can't just exist freely.
It's not a tutorial per se, but check out the C FAQ (http://c-faq.com/). It has a lot of good information on various sub-topics. Check out http://www.eskimo.com/~scs/cclass/cclass.html (scroll down and click on the intermediate notes, those start right at structures).
What NathanOliver gave you was a link to how to do input from and output to text files. Here's another link in that regard http://www.cplusplus.com/doc/tutorial/files/ It seemed initially like that was what you were asking about.
What kind of database would you be interested in? A database is probably overkill if you are just trying to maintain a list of those countries. If you really need a database check into MySQL (www.mysql.com), there is a C++ binding to interact with it.
Yes, as was said, 13 and 14 need to be placed in a function somewhere. Since your array is global (which isn't the best idea, but can be changed later) then they can go anywhere.
I had told you, you don't need the "electro" designation at the front of those two lines because account[0] is already of electro type.
Look at lines 60-61 for a minute. Firstly, you can only return one value, and secondly if you return from the function (line 60), the next line (61) is going to be skipped anyway.
You need to find a text or a good tutorial with a section on functions. You do not need the return type when calling them.
//headers, etc.
int return_int(int input); /*prototype, need the type here */
int main(void)
{
int y=2,z;
z = return_int(y); /*calling the function, don't need the return type or the parameter type*/
return 0;
}
int return_int(int input) /*function definition, need the return type here */
{
return (input-10);
}
You will need nested for loops:
for(over each of the rows)
{
for(over each of the columns)
{
Find a relationship between the columns and the rows. Take another crack at it, and post back with your updated code.
See this for a good overall tutorial: http://www.functionx.com/vccli/index.htm (the top box and the one marked GDI+ will be useful to you).
This tutorial is better than the GDI+ in the one above, but it's written for C#, so you'll have to translate the syntax to C++/CLI http://www.bobpowell.net/gdiplus_faq.htm
You need a break;
after the code in each of your case statements, else the control of the switch "falls through" to the next choice.
Changing the value of loop like makes your code difficult to follow, at least in my opinion. Get some more information on things like functions, etc. and your task will be somewhat easier.
This is in order to get the characters ascii value.
In a direct fashion:
std::string s = "123";
std::cout<<(int)s[0]<<std::endl; //outputs 49 (use your for loop to access all of the characters) the value of '1'
Please post your modified code (since we don't know what changes you made in the interim) with code tags [code] //code goes here [/code]
Bear in mind that what your have specified in the class declaration (up at the top) must match the method definitions (the functions below).
Thank you jonsca. I am sorry if I'm slow learner. Do you mean with codegear compiler cannot do anything to help me out?
It sounds to me like you are just getting started with C++, period. While this seems like a good starter project, it's not going to be possible without a library. If you know how to incorporate libraries into Codegear and make projects with them, then certainly go for it.
The compiler looks like GUI that make thing simple. If only OpenCV can help me. I would like to try it out.
Again, if you are just starting out, start at the beginning. Find some basic tutorials and work through them.
You can get a (free, legal) preview of a good OpenCV book on Google Books http://books.google.com/books?id=seAgiOfu2EIC&printsec=frontcover&dq=OpenCV&hl=en&ei=QYFCTYHRHYL2tgOryNzGCg&sa=X&oi=book_result&ct=result&resnum=1&ved=0CCcQ6AEwAA#v=onepage&q&f=false
Thank you for your reply. I've heard about OpenCV. This is some kind of additional library to the compiler right.
Yes.
Did you mean it is impossible to do that just with C++ languages it self? That would give me a real shock here.
Without using outside libraries, you'd have to be able to do some very low level (with respect to the machine, not ability level) calls to get the information off of the USB, organize all of the information, etc., so it's theoretically possible, but in practice you wouldn't do it that way.
I wanted to correct for my above post, the " character in single quotes doesn't need to be escaped.
You don't use u anywhere, so it's just assigned and forgotten.
Also, on 35, that's not going to give you the word count for the sentence, look up what strlen gives you for a result.
Okay, I did it, now what? What have you tried towards the problem?
You don't need the "electro" on declare anything on lines 9 and 10, account[0] is already of type electro. I think you'll need a different tactic for copying the string in too.
You are comparing character by character, so you need single quotes '\"' (since \" is considered to be one character).
Also, since you are comparing a true value with a true value, it will always be true, so the loop will run infinitely (and there's nothing in the loop body to change the value of u.
There is no standard functions to do this. You will need a library like OpenCV (or possibly something in DirectX, though I'm not sure of that). If you are just starting in C++, it may be too complicated to dive right into getting something like that to work with your compiler (unless you have experience using them in another language). Just trying to be realistic here.
Rather than use strlen to drive your loop, use the getline function directly:
while(inf.getline(email,maxRecLen))
{
//etc.
}
This way you won't need that initial read to get a value for strlen. When I tried it your way, I was getting an extra string. That if statement isn't doing anything either, so you can get rid of that.
I'm not exactly sure how to check if the list of emails has all emails with only one "@" character... Any ideas?
A string is essentially an array of characters with a null on the end. How would you search an array if you know the endpoint?
This is referred to as passing by reference. No, it does not need to be declared public. Consider an example:
void swap(int a, int b)
{
int temp = a;
a = b;
b = temp;
}
vs.
void swap2(int & a, int & b)
{
int temp = a;
a = b;
b = temp;
}
In main:
int x=10,y=6;
swap(x,y);
std::cout<<x<<","<<y<<std::endl; //output 10,6 since only copies were swapped
swap2(x,y);
std::cout<<x<<","<<y<<std::endl; //output 6,10 since the actual variables were swapped
So whatever string you send into that getLastName() method is being changed directly.
That being said, you could just return the variable, but if you needed more than one string returned, that wouldn't work.
I'd say pilot it as a sticky in a couple of high traffic forums (C++ and PHP come to mind, but not necessarily those). You'll get overlap from many of the other forums anyway, and then you can branch out from there. I agree with Ezzaral, posting anything critical in Game Dev (or any other low traffic forum) is a recipe for failure.
This version of getline should probably be your tool of choice http://www.cplusplus.com/reference/iostream/istream/getline/
Beyond that, which parts are stumping you? Can you open a file? Can you search through the characters of a string?
No problem! (our posts crossed). Good luck with your project.
I would take a "toy" problem and use the equations on pencil and paper. Take a circle with radius 3 and find the points where it intersects with the lines x = -3, x = 0, and x = +3 (you can construct lines with any two of the points along those, for example (-3,2) and (-3,-2) will make up x = -3(to keep calculations simple). You know that x = -3 will meet up with the circle at y = 0, so that should give you a discriminant of 0, you know that x=0 will meet up with the circle at (0,3) and (0,-3). Knowing that, you can come up with which should be + and which should be - (since both the x values are zero, you could choose a line with slope 1 passing through the circle to verify both x and y at the same time. It's possible the author of that page made an error and one should be +/- and the other should be -/+ (but I think using the signum he's trying to fix that). I wish I knew the absolute answer, but it should just take you a few minutes with pencil and paper.
The +/- accounts for there being 2 points of incidence if the value of the discriminant is greater than 0. If the discriminant is 0, there is one point of incidence (the first part +/- 0 gives the same point). If the discriminant is negative, there are imaginary roots and so no intersection on the real plane. It's the cases outlined in the diagram at the top of the page.
So, if the discriminant is greater than zero, you need to have one calculation for [x = Ddy + (signum) * the discriminant, y = -Ddx + the discriminant as one point] and [x = Ddy -(signum) * the discriminant,y = -Ddx - the discriminant] as the second point.
Hope that makes it more clear, if not post back. Just think of it as the solution of a set of quadratic equations and maybe it will click for you.
Sounds like a homework question to me. What do you think the answer is? Someone can then tell you if you are right or wrong.
Try using Int32.TryParse instead:
string str = "42"; //your string
int numb; //the number output from the method
if(!Int32.TryParse(str,out numb))
{
//it failed
}
See my edit, I had the name of your class wrong...
Post the code you tried for the pieceID part in the context so I can try it out.
I don't think this particular error has to do with the file.
TimePiece [] timePiece = new TimePiece[limit]
creates an array with room for Timepiece objects, but does not instantiate the individual objects
Around line 27 (but certainly before 33) you need something to the effect of
timepiece[i] = new TimePiece();
What is not working about it? What output are you getting and what is your expected output?
I suspect you are expecting both statements after your for loop to be executed at each step, but in reality only the one immediately following the for loop is executed each time. Put a set of { } around it.
Edit: just found your other thread
Hi jonsca: Thanks for helping me with the problem. Do you think is the destructor definition the problem here?
Danni
I did not trying running your program, but the vtable error is eliminated. See http://stackoverflow.com/questions/4351077/how-when-do-i-use-a-virtual-destructor for corroboration that the change I proposed is necessary.
Yeah, he's missing the destructor definition for extPersonType (not to "Me too" your post, but I was just working on seeing if the whole project would compile)
I don't do anything with GUIs or CLI, but I noticed you are using the compound addition operator to attach the EventHandlers. Maybe I'm missing something, but shouldn't that be the regular assignment operator, not a compound operator?
The compound operator is used there because it is possible to hook up more than one event handler to a single event.
Those ads have been doing that for years. Either click on the Software Development button and select your forum from the next page, or install Ad-Block Pro and NoScript.
...and/or sponsor for just pennies a day!! ;)
I need a program now..
This came across as if you were demanding someone to do your coding.
Sorry..I just to try an error..I am surprisingly shocked when I saw your reply..
I am not trying to ask someone to write the whole program for me, maybe I can retrieve a guidance as my reference from here..rather than blank in front of the pc..sorry if I had offended..
I appreciate your apology and your candor.
Edit:
However, looking at your program there are a handful of syntactical errors, but the greatest deficit is in the "key" functions to the program. In other words, I appreciate that you posted your code, but you still have many blanks to fill in. Unless someone knows GAs or can read about them quickly, you'll still need to bear the burden of these functions. See if you can come up with anything, even a pseudocode representation first.
Actually you posted this:
You told me to increment it once more when I was already incrementing it once after the j loop.
Ok, I can understand how that could be interpreted differently. I meant:
for( over the i's)
{
for (over the j's, incrementing k also)
{
}
//we've gone through one cycle of j's, so we've found a word
k++; //now increment
}
Hmm alright, do I put that bit of code within the for loop or in the place where I'm incrementing k but just before it. Also, what does this bit of code do exactly? I haven't come across something like std::cout while I'm learning C++.
That's how cout and endl are written with their fully qualified name. In standard C++ namespaces are used to allow you isolate two functions/classes/etc. that might have the same name. I suspect you might be using a prestandard compiler. Cout, endl, cin, etc. are all under the namespace "std." So, if I create a my own cout method under the namespace jonsca, then I can use jonsca::cout and std::cout to tell the difference. Some people use a "using" statement to bring all of the members from one namespace into the global namespace (like using namespace std;
)
So, you know what cout and endl are for, see if you can find a good spot in your code to output what you've just assigned to your array.
I had said to only increment it once after each word.
Put in a statement that looks like this:
std::cout<<"temp["<<i<<"]["<<j<<"] = "<<line[k]<<std::endl;
right after you've written it into the array (but before you've incremented k again)
This should show you where your storage of the chars is off. Part of the difficulty here is that you are using a loop variable that's not local to the loop. Once control goes back to the top of the for loop, j will increment one more time, then the condition will be tested.
Also I'm sorry but I don't quite get this. First you say I needn't worry about the part in bold then you say I need to but a '\0' after my last character by equating temp[j] to it after the j loop, but isn't that what the bolded part is doing?
Sure, sorry it's confusing. I'm saying you don't need to take the time to write in '\0' everywhere just to write over it again.
Most if not all functions dealing with cstrings will read only to the null terminus ('\0')
So if you have an array:
| | | | | | array boundaries
| $ | / | È | º | $ | declare it, there's junk in each space
| i | s | È | º | $ | write in 'i' + 's', if you try to output you'll get "is" + garbage
| i | s | 0 | º | $ | added the null terminus
Now if you check the length, the function will report 2 characters
If you do a strcpy, it will copy "is"+'\0' and nothing else
So, you can take the time to write in a null everywhere, but it's probably not necessary.
Others may have a different opinion...
Recently, I am doing my thesis project
I'm sure your supervising professor said, just throw it up on the web and turn in whatever comes back...
For someone to begin to help you with this, you need to bring your existing code to the table. No one is going to write this for you.
Perhaps time to reinstall the whole shebang, lol.
I know I could, I just wanted to break it all off into 3 separate ones so I could pull them out for quicker use in some other programs I will have to write later.
Well, that's a very sensible answer.
I think the getline buys you the ease of having everything in a string in addition to making the line numbering slightly less painful.
Check out http://www.cplusplus.com/reference/iostream/istream/seekg/ seekg.
Do you have to make 3 separate functions? You could definitely do it all in one pass.
Yeah I noticed the void too and tried to change it but it just stops it from compiling. Lame.
Just because it compiles doesn't mean it's correct lol. You probably didn't change it in both the declaration and the definition.
Sorry, I didn't know you were using C::B, in that system to get the -Wall (assuming you use it with the gcc) it's under Project/ProjectBuildOptions/CompilerSettingsTab/CompilerFlags and Enable all compiler warnings should be checked.
The only error I get when I compile it in VS (which only gives a warning in g++, oddly enough) is that you don't return a value from Set_A, which should be void anyway (or since you're doing some tests in it should return a bool)
Oh wow, there are a lot of errors, huh? I think i've fixed some of the converting int to LD. How exactly is it you put on the maximum warning level so I can check? Thank you.
Under:
project menu/<your proj name>properties/configurationproperties/CC++/warninglevel, change it to /W4
I'm not sure then, I'm not getting any error like that. Which compiler are you using? Sounds like Visual C++ if it's letting you step into the STL like that. Look and see if it's a known problem... otherwise, start a fresh program with just a vector initialized in it and see what happens.
Line 228
LD IFS::get_A(LD A)const
{
return matrix[A];
}
You shouldn't have a long double as an index of a vector.
(there are a fair number of other warnings as well, which you should address)
partymild1.cpp:59:30: warning: "/*" within comment
partymild1.cpp:60:9: warning: "/*" within comment
partymild1.cpp: In member function `LD IFS::set_A(int, const LD&)':
partymild1.cpp:225: warning: control reaches end of non-void function
partymild1.cpp: In member function `LD IFS::get_A(LD) const':
partymild1.cpp:228: warning: passing `LD' for converting 1 of `typename _Alloc::
const_reference std::vector<_Tp, _Alloc>::operator[](size_t) const [with _Tp = L
D, _Alloc = std::allocator<LD>]'
partymild1.cpp: In function `IFS operator*(const IFS&, const IFS&)':
partymild1.cpp:256: warning: converting to `int' from `LD'
partymild1.cpp:257: warning: converting to `int' from `LD'
partymild1.cpp:258: warning: converting to `int' from `LD'
partymild1.cpp:259: warning: converting to `int' from `LD'
partymild1.cpp:260: warning: converting to `int' from `LD'
partymild1.cpp:261: warning: converting to `int' from `LD'
partymild1.cpp:262: warning: converting to `int' from `LD'
partymild1.cpp:263: warning: converting to `int' from `LD'
partymild1.cpp:264: warning: converting to `int' from `LD'
partymild1.cpp: In function `IFS operator+(const IFS&, const IFS&)':
partymild1.cpp:270: warning: converting to `int' from `LD'
partymild1.cpp:271: warning: converting to `int' from `LD'
partymild1.cpp:272: warning: converting to `int' from `LD'
partymild1.cpp:273: warning: converting to `int' from `LD'
partymild1.cpp:274: warning: converting to `int' from `LD'
partymild1.cpp:275: warning: converting to `int' from `LD'
partymild1.cpp:276: warning: converting to `int' from `LD'
partymild1.cpp:277: warning: converting to `int' from `LD'
partymild1.cpp:278: warning: converting to `int' from `LD'
partymild1.cpp: In function `IFS operator-(const IFS&, const IFS&)':
partymild1.cpp:285: warning: converting to `int' from `LD' …
I'm not sure. Post your code as an attachment (using the advanced editor and uploading it).
Where do you typedef it to LD? or is that just an abbreviation when you posted?
You have chosen the wrong kind of project. You need to choose a Win32 Console Application from the initial menu. Start a new project and copy your code in, you should be good to go.