>I am getting a segmentation fault when i run the follwing program.
How does your code handle N^0?
>Code tags work sometimes and code tags donot work.
Define "do not work".
>I am getting a segmentation fault when i run the follwing program.
How does your code handle N^0?
>Code tags work sometimes and code tags donot work.
Define "do not work".
Alright serkan sendur, that's quite enough. I've been ignoring your creepy and unhealthy fascination with me thusfar, but now you're getting dangerously close to harassment.
>No reprimands for sid! He's just the greatest! Why don't you give
>him yet more rep? Obviously he's the kind of person that Daniweb wants!
I believe AD was referring to everyone. But I will add that those most offended by a general reprimand are often those with a guilty conscience. ;)
>1. Know the subject (and their own limitations).
I try to.
>2. Explain things clearly (and carefully read what others say).
I try my best.
>3. Be nice. (Why not?)
I'm not nice. At all. And I have my reasons, though the people who try to emulate me don't get it, and the boy scouts don't want to. If your opinion of me is very high, how is it you tolerate me only having two of your three qualities?
>Goodbye, cruel Daniweb! (for good this time)
I've seen that threat many many times, and I've only seen it carried out successfully once.
#include <iostream>
#include <string>
class Foo {
public:
Foo() { throw std::string ( "poop" ); }
};
int main() try
{
Foo f;
}
catch ( const std::string& msg ) {
std::cerr<< msg <<'\n';
}
>Bjarne states that standards doesn't stops the
>implementors to reset the pointer just deleted to NULL
The standard doesn't stop them, common sense does. Adding an extra operation (assigning null to the pointer being deleted) introduces all kinds of problems. Here are a few:
Automatically setting the pointer to null adds complexity and buys nothing, taking into account that this task is trivial without adding compiler behavior, and the programmer is in a better position to use it judiciously.
>But what annoyed me really was the reply of Nucleon. Seriously, that took my nerves apart.
It looks to me like nucleon replied to you in the same tone that you replied to the OP.
>But can you (or anyone here around) seriosly answer that question?
Yes, as a matter of fact I could have answered all but one of the questions asked by the OP. The only question I can't answer conclusively (because I wasn't there) is the question about whether this feature was talked about in …
And what have you done to help yourself first? Your question sounds a lot like "I don't want to think, do it for me."
>Honestly, I don't think anyone in the class has this figured out
I'm not surprised. Assuming you've given me the same requirements your teacher gave you, there's really no way you can solve the problem adequately. Since he changed the rules, you need to know the new rules before you can follow them.
You currently have one case:
^ ^ 2 3 4 = 2^81
What about the case you've replaced?
^ 2 ^ 3 4 = ?
What about the infinite recursion you should be able to handle correctly? What are the rules for three operators? Four? Fifty? What if they're not all adjacent? You lack sufficient information.
>std::transform(msg.begin(), msg.end(), msg.begin(), std::tolower);
Congratulations, you've propagated one of the more annoying bugs among C++ help forums[1].
1) tolower isn't just a function in <cctype>, it's also a template in <locale>, which is allowed to be included by any standard header (<iostream> is the usual culprit). As written, there's an ambiguity and the name can't be resolved[2].
2) The usual "fix" is also wrong:
std::transform(msg.begin(), msg.end(), msg.begin(), (int(*)(int))std::tolower);
I consider this a casualty of overly clever programmers trying too hard to retain the one-liner status of this solution. However, it's wrong because tolower expects an integer argument in the range of unsigned char. If vanilla char is signed on your system, you've got problems because plenty of valid negative character values can be promoted to int and fall outside the range of unsigned char. The code will compile but is non-portable at best and undefined at worst.
The correct solution would be some variation of this:
struct uppercase {
int operator() ( int c ) const
{
return std::toupper ( (unsigned char)c );
}
};
std::transform ( msg.begin(), msg.end(), msg.begin(), uppercase() );
[1] Annoying because it's incredibly subtle, doesn't always exhibit buggy behavior, and everyone and his brother will try to argue its correctness. :icon_rolleyes:
[2] Technically the name can be resolved, as the information is present to do so if the implementer chooses to do the extra work of gathering it, but it's not a standard practice, so you'd be relying on …
>c++ is a better way to attract Narue's attention, i am honored when i get posts from her.
That's sad. The really pathetic part is that you're probably serious. :icon_rolleyes:
>Also I have googled for "windows form application in c++" and very little has comeup!
Really. None of the 35 million hits was even close to relevant? I find that hard to believe, especially when the first page looks both relevant and useful.
>How can I do this?
Handle the click event for your button. Inside the event handler, you'll create an object of the OpenFileDialog class. Once you have the path of the selected file, you can use one (or more) of the many stream I/O classes to load the contents into a string. Then copy that string into some kind of textbox control.
You can only switch on integer values. This restriction makes more sense when you think of a switch statement as a table lookup where each case is an index into the table.
>switch (choice[0], choice[1], choice[2], choice[3], choice[4])
>and that didn't give me a compiler error, but would this be correct?
It doesn't give you an error because char is an integer type, but it's not going to do what you want (I suspect). Generally people who aren't familiar with the comma operator are surprised with the result.
Now for the problem at hand:
>I'm prohibiting the user, that he can only enter 5 keys.
You can't really restrict what the user enters, but you can handle invalid input gracefully:
#include <iostream>
#include <string>
bool is_valid ( const std::string& s )
{
return s == "a" || s == "b" || s == "c";
}
int main()
{
for ( ; ; ) {
std::string choice;
std::cout<<"Enter a choice: ";
if ( getline ( std::cin, choice ) &&
is_valid ( choice ) )
{
std::cout<<"Woo-hoo!\n";
}
else if ( std::cin.eof() )
break;
else if ( !std::cin )
std::cout<<"Stream error\n";
else
std::cout<<"Invalid choice\n";
}
}
>I don't know exactly why it's needed either.
There's the potential for a parsing ambiguity when you use dependent names[1]. Let's look at an example:
template <typename T>
void meep()
{
T::Baz *p;
}
Clearly this code is intended to create a pointer to T::Baz and T::Baz is a type, right? Not quite. What happens when T is instantiated into the class Bar below?
class Bar {
public:
static int Baz;
};
Now T::Baz *p takes on a whole new meaning. Since Baz is actually an object after template instantiation, the expression now says to evaluate the product of Baz and p, then throw it away. Since p doesn't yet exist, that's a syntax error in this case, but it shouldn't be hard to see more subtle errors that will compile and simply not do what's expected.
The dependent name rules and the typename keyword help alleviate this problem. The dependent name rules state that without the typename keyword, dependent names are assumed to be non-types (hence, your error). If you really want a type, you need to apply the typename keyword, which will remove the ambiguity and the Bar case above will fail to compile instead of silently do something unintended.
[1] A dependent name is a name that relies on a template parameter such that the name doesn't really exist until the template is instantiated.
>It doesn't seem to me that creating this would cause a segfault...
Just because it dies there doesn't mean the problem occurs there. Don't confuse the symptom for the cause and you'll understand why memory errors are among the more insidious bugs you can encounter.
Sadly, you haven't provided enough information for me to help you. Try writing a complete bare bones program that exhibits the problem so some of us can troubleshoot on our side.
>i have no clues on how to begin this
Then either you weren't paying attention in class (if you're a student) or you're woefully unqualified for your job (if your a professional). I'm especially unsympathetic to people who claim not to have a clue and then ask me to do their work for them.
>can anyone plz send me an algorithm on face recognition using neural networks??
Dude, do you have any idea how ridiculous that sounds? It's almost as bad as the noobs who ask for a complete 3D game engine that they can plug in to a bag of fairy dust and make millions from their "AWESOME Halo killer!!!11one" game idea.
>Coders will have your head for not using argc and argv. xD
Nah, but the hungarian notation will start wars. ;)
Meh, it's your call.
Let's start with some design decisions:
>void timestamp_string (char * myString)
The first thing I notice is the inconvenient notation caused by returning void. You can take a trick from the standard library and return the result string as well as let it just fall out of being a pointer parameter:
char *timestamp_string ( char *myString );
/* ... */
printf ( "Timestamped: %s\n", timestamp_string ( name ) );
That's cleaner in my opinion. The function name is also redundant. Obviously it's working with a string, so you could break it down to just timestamp, or perhaps, append_timestamp. However, when I think of a timestamp, I think of a prefix rather than a suffix. It's both easier to see in a string and easier to sort on when the timestamps is the first thing[1].
Let's do that magic and take another look:
char *prepend_timestamp ( char *s )
{
const char fmt[] = "[%y-%m-%d %H:%M:%S]";
const size_t n = sizeof ( fmt );
const time_t init = time ( NULL );
memmove ( s + n, s, strlen ( s ) + 1 );
strftime ( s, n, fmt, localtime ( &init ) );
s[n - 1] = ' ';
return s;
}
The first thing that raises a flag for me is the lack of error handling. It's not possible with the current interface to verify that adding the timestamp won't overflow your string. The interface needs to change, …
>In c++, an even easier way is to use the c++ transform() function
It's not easier when you do it the correct way:
#include <algorithm>
#include <iostream>
#include <string>
struct UpperCase {
int operator() ( int ch )
{
return toupper ( (unsigned char)ch );
}
};
int main()
{
std::string str = "hello world";
std::transform ( str.begin(), str.end(), str.begin(), UpperCase() );
std::cout<< str <<'\n';
}
Why so complicated? Because for various annoying and obscure reasons that I've explained before, using toupper directly like you did is non-portable at best and undefined at worst.
>Hope helps.
Congratulations, it only took you seven days longer than Ancient Dragon to discover the same problem and post the same solution. :icon_rolleyes:
>A field such as First Language and possibly one for additional
>languages spoken might be useful for those who take issue with
>people struggling to describe the problems they are having.
In my experience, we're generally pretty good at determining if the communication barrier is due to legitimate language problems of a non-native English speaker or sheer laziness. The reaction tends to be pretty accurate as well. Legitimate difficulties receive sympathy and patience, laziness receives a healthy dose of attitude.
That said, a "languages spoken" list might be a nice touch.
>What can .net be used for? what is it good for?
In my opinion .NET is best used for applications and services where the overhead of the framework is acceptable. I can't stress enough how much more pleasant GUI applications are to write in .NET than in Win32 or MFC. It can be used for a lot of things, and that list is growing steadily.
>.net vs. gtkmm?
.NET is much bigger than just a graphics library, so I'd say Windows Forms vs. gtkmm would be more appropriate. And I'd also say (my personal opinion) that the design of Windows Forms is superior and easier to use. Then again, I'm not a GUI programmer by any means, so easier is a huge benefit for me.
>Can i use the .net framework with c++? and how?
Yes, you just need the .NET framework and a compiler that recognizes C++/CLI. Be prepared to supplement your C++ knowledge with apparently redundant (but different) features, because C++/CLI is C++ with a bunch of extra features for supporting .NET.
>ive been googling "c++.net tut", "Visual c++ tut", ".net framework tut" etc. all day
Search for "C++/CLI", that's the official name of the new language. Also note that C++ and C++/CLI are two different languages as C++/CLI adds non-standard features to incorporate the .NET framework.
>Some say C# is easier to use with the .net net framework, is that true?
Yes. I can say without hesitation that …
I can't help but reply since I'm probably one of the 'Vets' the OP is talking about. ;)
>why does it seem like some of the posts here are an ego-contest?
I'd wager it's because programmers tend to have big egos. It's also a game, which I'll describe shortly.
Result 1: Student/User asks for help, another Student gives help then a Vet comes in and provides a better solution that the original poster doesn't understand because it contains much more information than what the OP originally asked for.
Nearly always, the second student gave a substandard answer that's littered with bugs and misunderstandings. Rather than let the OP get led astray by an unqualified yet well-meaning helper, we jump in and offer corrections or a superior alternative.
Even if the second student by some miracle provides a flawless answer that's perfect for the OP, there are still alternatives upon alternatives and nuances upon nuances that the second student may not be aware of. A 'Vet' will be able to share insights that both students can learn from.
Result 2: Original Poster has no idea on how to start the assignment and posts the question, yet individuals immediately assume that the OP is requesting the answer and not some hints on how to start.
Past behavior is an indicator of future behavior. If 99% of the "I don't know how to start" questions ultimately end up being "Gimme the code! GIMME GIMME DAMMIT GIMME!!!!!111oneone" then we're …
>how do I sort both department and gender?
The keys are rolled up in a single object, so all you need to do is modify your comparison for the sort. Try comparing both the department and the gender in the same if statement.
This thread is being closed due to violation of Daniweb's homework policy. Read our rules, try it yourself, and then create a new thread if you need help (help != handouts, by the way).
I haven't received enough feedback to confidently say if this is a good enough and detailed enough article, but I'll suggest it anyway.
>wanna tell me which part is gonna confuse people so i can better explain it?
Let's see...maybe...possibly, the part where you answered a completely different question from the one that was asked. The OP asked what the advantages of the two loops are (with advantages in all caps, I might add, so not really easy to miss).
>or could i just be confusing you o.0
You're welcome to try. Usually people around here only manage to confuse me with incredible stupidities.
>i have seen you post around. i wont waste my time with you.
What a shame. I'm sure it would be quite entertaining if you went on a quest to bring me down. People who do that are always good for a few weeks of amusement.
>Also if you have a big experience then you should
>know it is not a big deal that people can correct you.
It's not a big deal at all...when they're right. Just because you think you're right doesn't mean you are.
>I'm not saying I am an expert but you are wrong
>about what you've written in previous post.
Prove it. I can prove that until you initialize a pointer with an address to memory that you own (ie. an existing array or calling malloc), you invoke undefined behavior. Sometimes undefined behavior appears to work just fine, which is likely what's happening in your case. But "works for me" is a far cry from "correct and bug free".
So tell me, are you truly saying that you believe the following code is 100% correct, that scanf magically allocates memory to s or that s magically points to infinite memory, and that I'm completely wrong in saying that it's broken?
#include <stdio.h>
int main ( void )
{
char *s;
if ( scanf ( "%s", s ) == 1 )
puts ( s );
return 0;
}
>although you said it is broken I initialize the str every time I read a word from the file.
Hmm, I can interpret this one of two ways:
If it's the first case then I would highly recommend that you post equivalent examples to your real code if you want any useful help. If it's the second case then I pity you, because I'm very rarely wrong when it comes to the standard language/library, and when I am it's not the people asking beginner questions who are able to correct me successfully.
Arbitrary length input takes more work, and often the basic input functions are weak without a bit of scaffolding around them to get what you want. For example, here's a delimited string input function that can be used to read words:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define GROW_BY 32 /* Arbitrary size */
char *reads ( FILE *in, char *delim )
{
char *result = NULL;
size_t size = 0;
size_t capacity = 0;
int ch;
while ( ( ch = getc ( in ) ) != EOF ) {
if ( size == capacity ) {
char *temp;
capacity += GROW_BY;
temp = realloc ( result, capacity + 1 );
if ( temp == NULL ) {
/*
This is a weak solution because …
Have you looked into the standard library? There's a std::unique and std::unique_copy function.
Assuming you're working on Windows, learn about the PE (portable executable) file format and you can easily extract the information you want either manually or with any number of disassembly tools.
>one of my classmates recently said that - according to what he
>heard- writing one line of coldfusion is the same thing written with
>100 lines of c#, remembering that kind of fallacy
The only fallacy is you using hearsay ("I heard it from my classmate who heard it from somewhere") as fact.
>it is better to have a good comparison among the options before starting.
That's a fabulous idea. I strongly suggest that you follow that advice, since clearly you lack the experience necessary to compare ColdFusion to anything, much less recommend alternatives to it.
if ( option == 'y' )
// continue
else if ( option == 'n' )
// exit
else
// print error
>its free and easy to use.
I'll certainly agree that Linux is easier to use now than it used to be. But back when it was a royal nightmare even for technical people to move to Linux, the fanboys were still saying the same thing: "it's free! and easy to use...really, I swear!".
>i dont know, i just like how easy it is to change.
Change is always difficult. I once tried convincing my boss to switch to SVN for source control and got shot down because it would cost too much in man hours. They ultimately made the switch after a losing a lot of money from a source control boo-boo, and the boss' estimate in man hours wasn't far off the mark. It was neither easy nor cheap, but they're happy with the result.
>and most of the applications are free...
There are degrees of free. There are degrees in between as well, but here are the primary three:
Open source software tends to gravitate toward #2 due to the programmer attitude toward ease of use (and open source software is pretty much controlled by programmer whims), though it's getting better.
>it fascinates me that more people dont use it!
I can't imagine why. Pretty much the entire reason Linux exists at all is political infighting among the alternative vendors at the time. Why is it so surprising that vendors with an existing foothold aren't budging much when Linux comes around? Free[1] is all well and good, but familiar is usually preferred.
[1] Assuming (as open source advocates usually do) that your time is worthless. "It's totally free! Excluding the many hours you'll spend learning a new skill set and being frustrated with the tools a programmer though would be intuitive".
>you're the first person I actually agree with in this thread. Well done.
I think you single-handedly destroyed my chances of getting on Daniweb's payroll. Dani will never trust me again now that the iamthwees of the world have started agreeing with me. :icon_rolleyes:
>When you compared your current knowledge to back then, do you see big changes?
Absolutely. If I can manage to go over four years without learning anything significant, it's time to retire.
When I joined there were a bunch of know-it-all wannabes running around giving bad advice in the C and C++ forums. I'm fairly confident that my first post was a correction to one of their posts.
The earliest post I can successfully find is on September 26, 2004 (clicky), which is pretty close to my join date, but still short ten days worth of posts.
>But it shouldn't see the end of file until after the 4th line is read, not the third, right?
I think you're confused about the meaning of end-of-file. You're thinking of the file itself, not the stringstream. The two objects are completely independent of each other and have no idea that the other exists.
The stringstream is only aware of the one string you used to initialize it. This is the line you use to initialize the stringstream:
512 512
As far as the stringstream object is concerned, that's the entirety of the file. After you extract the two integer values from the stringstream, the object goes into an end-of-file state.
>as these both topics are vast and very time consuming
Perhaps if you're trying to get a PhD or something in one of them. But as a practicing programmer, you can easily learn enough about both to improve yourself. Learning one topic to the exclusion of equally important topics is a very bad idea. You'll end up being the guy who always suggests the same solution because he doesn't understand anything else.
Remember, you want to be well rounded, even if it means you aren't a guru (yet!) in any one thing.
>In spite of what Narue said, programming isn't hard by itself.
You could only have that opinion if by "programming" you mean "typing code". People who say that programming isn't hard are either too inexperienced to know, or flat out lying.
>I honestly believe that it's essentially the same
>as writing, once you begin to understand it.
The writing part is relatively simple because there are rules and plenty of examples to follow. Of course you also have to come up with a compelling story, interesting characters and character development within the story, a plot suitable for at least one self-contained book, subplots to keep the reader interested, and fast enough progression to hook readers but slow enough to tell the whole story without losing depth.
On top of the story and characters you often need to build the world around them such that it seems realistic enough to draw readers in. This could go as far as creating complete languages and the history of the universe (à la Tolkien), or it could be as simple as enough history to give the world depth even though you couldn't possibly write enough books to cover everything (such as McCaffrey's Pern). Failure to do this usually results in a flat and boring world, and the story ends up being flat and boring as well.
You have to maintain continuity throughout the development and writing process, and watch out for errors of all kinds (both writing and …
>How did you learn programming ?
Practical experience. I taught myself the basics and expanded on that as I did projects. Programming is one of those fields where you don't need a degree, and it's easy (these days at least) to get started and go a long way without formal education.
>I am not the best at it at all by any means
Nobody started out knowing what to do and how to do it. We all needed to learn how to solve problems effectively and efficiently. Unfortunately, there's really no shortcut. Mistakes, as they say, become experience.
>Is this a normal thing for people?
Yes. Despite what people trying to sell you something will say, programming is hard. Not only is it hard while learning, it remains hard throughout your career (though the hardness changes as you improve).
>Have any of ya felt this same way that I do?
I like to describe myself as the result of untalented hard work. I don't have any natural talent for programming, so yes, I've felt the same way you do.
>And how do you overcome it and persevere with it?
I relied on the high of finally solving a problem. When you reach that point, it feels so good that you forget about all of the pain you went through to get there. More recently I've learned to take pleasure in aspects of the journey as well as the solution.
>If you're struggling while learning, you're learning wrong.
If you're not struggling while learning, you're not pushing yourself hard enough.
>I've been told that Information Technology requires less math then a CS degree.
Maybe to get the degree (I wouldn't know, I don't have a degree), but the kinds of jobs you'd get with either a CS or IT degree will require math. Consider yourself warned.
>What worries me though is how far a degree in IT would get me compared to a CS degree.
An IT degreee will get you just as a far as a CS degree will: the interview for your first real job. Beyond that it's all about experience.
>I'm concerned about job security, salary, and the prestige of one degree to another.
Job Security: If you're depending on your degree for job security, then you don't have any job security.
Salary: In reality a degree won't help your salary like it would, say, a teacher's. A rock star IT guy or programmer will command just as high a salary if he dropped out of high school as he would with a PhD in computer science, electrical engineering, mathematics, and quantum physics. Experience and ability rules in our field. The degrees and certifications are really just there to get a resume past the semi-automated sorting heuristics.
Prestige: I imagine you'd get more prestige with a CS degree than an IT degree, though it depends on what's involved in the degree. However, that kind of prestige is superficial and ultimately worthless. Please don't become a blowhard who flashes his education …
>Why do people make a big deal about dates???
It concerns how the forum handles recent activity. If you post to a thread that isn't currently on the first page, you bump it up to the first page, which sends a thread that is on the first page down to the second page.
Paging is important because most people don't browse to the second page. Falling to the second page is basically a death sentence for a thread and if it isn't a solved thread, you've ruined the OP's chances of getting an answer.
It's a breach of netiquette and considered extremely rude because the ancient thread you've resurrected was either answered or abandoned and we consider it far less important than the recent thread you shoved away to get the ancient one to the top of the list.
So why do people make a big deal about dates? Because unlike you, we're considerate enough to think about the people who need help now as opposed to any selfish addition to a forgotten discussion that we might be able to make.
>Can somebody explain why in the code below, when i use free(), it crashes.
That's easy. You corrupted the memory and the dynamic memory manager is choking because the corruption removed something it expects to see. A common situation that causes this problem is failing to allocate enough memory for the entire string and the terminating null character, but you'll need to do some index counting to find out exactly where the corruption is (you're writing beyond the boundaries of the memory you allocated).
Old joke. Lame.
The cast is bad in C. It hides potential errors such as forgetting to include <stdlib.h> and makes maintenance more difficult if you change the type of the pointer, so you'd best get into the habit of not casting the return value. Pointers are implicitly converted to and from void* with no complaints, so there's no good reason to cast anyway.
Here's a much improved form:
/* Allocate one object */
p = malloc ( sizeof *p );
/* Allocate N objects */
p = malloc ( N * sizeof *p );
The cast is a throwback from the dark ages when char* was the generic pointer rather than void* and there wasn't an explicit conversion rule in place.
>i searched google, trying three wrong examples, having compiler errors
I searched Google and the first hit was a correct example. But go ahead and do whatever makes you feel special. :icon_rolleyes:
>temp = arrayItem; // swap elements
>arrayItem = arrayMove;
>arrayMove = temp;
This won't do jack squat because you're just swapping the pointer values, not the data stored at those addresses. Ignoring the fact that with C++ you should be using templates instead of the much more error prone void* for generic typing, here's an example of a sorting algorithm for an array of int and the corresponding generic algorithm using void*:
void sort ( int a[], int n )
{
int i = 0;
while ( i < n ) {
if ( i == 0 || a[i - 1] <= a[i] )
i++;
else {
int save = a[i];
a[i] = a[i - 1];
a[i - 1] = save;
--i;
}
}
}
typedef int CompareFunc ( const void *a, const void *b );
void sort2 ( void *a, int n, int size, CompareFunc compare )
{
unsigned char *save = (unsigned char*)std::malloc ( size );
unsigned char *bytes = (unsigned char*)a;
int i = 0;
while ( i < n ) {
if ( i == 0 || compare ( &bytes[(i - 1) * size], &bytes[i * size] ) <= 0 )
++i;
else {
std::memcpy ( save, &bytes[i * size], size );
std::memcpy ( &bytes[i * size], &bytes[(i - 1) * size], size );
std::memcpy ( &bytes[(i - 1) * size], save, size );
--i;
}
}
std::free ( save );
}
>The title is a bit confusing so Ill explain.
Unless you didn't say what you meant, I understand your problem perfectly just from the title. Have you tried storing the used random numbers and then searching that list when you need another? A naive solution is pretty obvious and trivial to implement, so I'm leaning toward thinking that you're too lazy to put forth any real effort.
>Kinda important so bumping up...
Bumping is a fantastic way to make sure your question doesn't get answered. It's presumptuous to believe that you're more important than everyone else, and many of us don't want to help people like that.
>An aggregate class is [...]
Also known as a POD (plain old data) type.
>how will i fill the items of that array?
If you want to initialize it with a list like with the single C object, it's just the nested equivalent (really no different in principle from how you initialized d):
struct C c[4] = {
{1, 2},
{3, 4},
{5, 6},
{7, 8}
};
After the array is initialized (whether you use an initializer or not), you can't use an initializer later on because they're only allowed in definitions, so this is illegal:
C c[4];
c[0] = {1, 2};
In such a case you would need to manually fill out the data members:
C c[4];
c[0].a = 1;
c[0].b = 2;