when i compile this program

main()
{
  struct emp
  {
     char name[20];
    float sal;
  };
 struct emp e[10]; 
int i;
for(i=0; i<=9; i++)
  scanf("%s %f", e[i].name, &e[i].sal);
}

it gives the Floating point formats not linked

but when i run this

main()
{
  float x;
 scanf("%f" , x);
}

<< moderator edit: fixed [co[u][/u]de][/co[u][/u]de] tags >>


it gives no error

i got the explanation of first question as
compiler encounters a reference to the address of a float so this is error

in the second program we are also passing the address of x

thn why not error

is i missing something that is not clear to me
plz explain what is going on in both the program

scanf("%f" , x);
/*
[560 Warning] argument no. 2 should be a pointer
*/

Whenever you compile C code you should enable warnings. Some compilers will not complain unless you tell them to complain.

What compiler are you using? Is it an ancient version
of BORLAND C++ or TURBO C? You really need to use a modern compiler - there are free ones on the internet starting with gcc.

And in general, don't compile straight C with a C++ compiler even though it seems to work.

oops
Dave Sinkula i don,t see that in hurry

that is

scanf("%f" ,&x);

and i am using dev cplusplus 4 version now

but strange there were no problem in both code when i run it on dev 4 version

plz tell me in dev 4 version how i ll see my output window it takes input in command line console but not show the output

i am totally novice for it

See This
http://www.daniweb.com/techtalkforums/thread33624.html

YES I SEEN THAT THREAD
i am using devc++ 4.0
and it show that there is no
#include <limits>

c:\doublly_.cpp:5: limits: No such file or directory

and it also not working with

system("PAUSE");
i also include
#include <stdlib.h> directory

what is error

Well, <limits> is a standard C++ header. And Narue's code compiles just fine as-is using Dev-C++. Perhaps johnray31 could be so kind as to copy the exact code and post it here within [co[u][/u]de][/co[u][/u]de] tags. It's so much easier that way.

Sorry for that...i should have checked that before posting...i have always used <climits>.....yes<limits> is a standard header and works fine in DEV...so better post ur code

Well, <limits> is a standard C++ header. And Narue's code compiles just fine as-is using Dev-C++. Perhaps johnray31 could be so kind as to copy the exact code and post it here within [co[u][/u]de][/co[u][/u]de] tags. It's so much easier that way.

here is my code and plz look one place i mention one error that i am not able to see becz i couldn,t see console output

#include<iostream>
  #include<conio.h>
  #include<alloc.h>
  #include <stdlib.h>
  #include <climits>
  using namespace std;
	typedef struct node
	 {
		int value;
		struct node *next;
	  struct node *prev;
	  }node1;
	node1* head=NULL;
	void buildlink(node*);
	void addition(node*);
	void showlink(node1*);

  int main()
	{   // node1* temp=head;
		for (int x=0; x<2; x++)
		  buildlink(head);
		  showlink(head);
		  //addition(head);
      cin.ignore ( numeric_limits<streamsize>::max(), '\n' );
     cin.get();
      return 0;

	  }
	void buildlink(node *linknode)
	 {  int temp;
		 cout<<"enter ur node value"<<endl;
		 cin>>temp;

		 if(linknode==NULL)
		  {
			 head = (node1*)malloc(sizeof(node1*));
			 head->value=temp;
			 head->next = NULL;
			 head->prev = NULL;
			}
		  else
			{
			 while(linknode->next!=NULL)
			  {
			  linknode=linknode->next;

			  }

			  cout<<linknode->value<<endl;
			  linknode->next=(node1*)malloc(sizeof(node1*));
				linknode->next->prev=linknode; [B]//it is not taking the value of linknode[/B]
				cout<<linknode->next->prev->value<<endl;
			  linknode->next->value=temp;

			  linknode->next->next=NULL;


			  //cout<<endl<<temp1->value<<endl;
			}
		 }
	  void showlink(node1* link)
		{  node1* previous =link;
		  cout<<link->value<<endl;
		  while(link->next)
			{
			  cout<<link->value<<endl;
			  link=link->next;

			}
		  while(link)
			{
			 cout<<link->value<<endl;
			 link=link->prev;
			}
		 }
	  void addition(node* link)
		{  int x,val;
			cout<<"enter position u want to make addition and value "<<endl;
			cin>>x>>val;
			for(int y=1; y<x; y++)
			 link=link->next;
				 node1* temp2 = (node*)malloc(sizeof(node1*));
			 temp2->value=val;
			 temp2->next=link->next;
			 link->next=temp2;
          showlink(head);
		}

Codes compiles with no errors but gives warning bcoz ur using deprecated headers...dunno about ur logic maybe some logical errors also....

I'm not looking that close, but what kind of output would you expect. I get this.

enter ur node value
2
enter ur node value
25
2
2
2
2
25
2

but in my dev 4.o it gives error

c:\doublly_.cpp: In function `int main()':
c:\doublly_.cpp:24: `numeric_limits' undeclared (first use this function)
c:\doublly_.cpp:24: (Each undeclared identifier is reported only once
c:\doublly_.cpp:24: for each function it appears in.)
c:\doublly_.cpp:24: parse error before `>'
c:\doublly_.cpp:24: implicit declaration of function `int max(...)'
c:\doublly_.cpp:24: parse error before `)'

Perhaps it's time to get the latest version of a free compiler?

Why are you using malloc in a C++ program?

Why are you using ancient headers?

Perhaps it's time to get the latest version of a free compiler?

Why are you using malloc in a C++ program?

Why are you using ancient headers?

u said in ur previous reply that it was running ?

actually this program was in c

so till now i i didn,t change it but i ll change it

how u run it and get the output plz tell me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.