so this was a syntax error? really?
when i write it like this:
char foooo()[10]
{
}
my compiler reports that the function returns array! i am using MSVS .Net 2003.
Type: Posts; User: msp
so this was a syntax error? really?
when i write it like this:
char foooo()[10]
{
}
my compiler reports that the function returns array! i am using MSVS .Net 2003.
char foooo()[10]
{
static char a[10];
return a;
}
I am really screwed up! What's wrong here?
Print the binary tree on console in a visual way ;)
Well I tried whatever I could think of but the program runs fine.
So why worry :)
Yeah Salem I am doing that!
But I think (I've seen it in MSVC while writing this example) that the function "push_back"
takes a reference. So no new copy should have been made.
I think it is a special case for string objects only.
What if the objects are of other types?
I am trying to do it with my own objects, and I will post them here.
Salem, sorry for that stupid error!
Now the program works just fine :shock:
I am expecting it to show invalid data or make invalid memory errors.
Why is it working just fine? (Contrary to my...
Here in this code the function "foo" adds local objects to a global list.
Then the function "bar" tries to access the list. In this simple example it worked.
(I was expecting some garbage values or...
Thanks Salem for pointing this out!
I have made the modifications.
Hi Codeplug!
But what these lines are doing in his code?
I think they are supposed to have the same effect?
#if defined(_MSC_VER)
#pragma comment(lib, "ole32.lib")
#pragma comment(lib,...
My version of animal guessing game in C:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
struct tree_t
{
char* item;
struct tree_t* left;
matsp, i tried with gcc -O0 fptr.c
but this also did not help.
i am making an indirect recursion, through a function ptr, i thought it would work, but ...
Even this did not fell into an infinite recursion!
Damn!
Even this did not work :(
int (*foo) (int, char**);
int bar(int c, char** a)
{
foo = bar;
foo(c, a);
}
Oh so may be there are some problems related to recursion of the main method in C.
Not a problem I will try the above with a different function.
Thanks.
I tried this and was expecting it to recurse infinitely (until stack fault).
But it did not.
int (*foo) (int, char**);
int main(int argc, char** argv)
{
foo = main;
...
well ziga, I hope this helps you:
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
string line;
getline(cin, line, '\n');
:confused: sorry :confused:
Could not make any sense of it.
Just tell me what you want to do?
My own auto_ptr implementation:
#include <iostream>
using namespace std;
template <typename T>
class ptr
{
T* p;
public:
It works now! Thanks everyone!
#include <iostream>
#include <cstdlib>
using namespace std;
struct Node
{
int item;
Node *left;
Yeah iMalc!
I am actually a An Idiot at C++ and posted my tiny examples here for my own reference and
any newbie like me (who may see them useful).
Thanks brewbuck!
Yeah! But I am unable to PM him.
This is what I get when I try: Error Page
I can be (or give you) a mentor for 1 year and even longer time.
But first tell me how much can you pay? Can you pay me $50 per month?
Regards.
Thanks simpleid!
All your examples look very useful (have not run yet)!
Please suggest a better alternative for that!
Well I just want it to insert items in tree and then print the inserted items.
Oops! I did not realize that. Thanks.
Yeah I hope that reference to pointer may work. I'll test it and post....