Sharing variables in C/C++?
445541
The best way is to use a header file, call it whatever you want such as "global.h". In there \nyou declare a class with a public static data member. This is always a declaration and does not require an extern keyword. Then in one file you define the static variable. You can use that variable in any number of files. Here's an example:\n\nFile "global.h":\nclass Global\n{\npublic:\nstatic int var;\n};\n\nFile "global.cpp":\n\nint Global::var = 42;\n\nAn any other file use Global::var to refer to the shared variable.\n\nSometimes this doesn't work with dynamically loaded libraries. In that case, what you do is declare a static function which returns a reference to a static variable. Whenever the variable needs to be accessed, you call the static function.
963773
It is done in C/C++. U can check that out in any of the windows programming books.
172063
http://www.thefreecountry.com/compilers/cpp.shtml
750295
check out http://www.planet-source-code.com for examples.  I don't do C, but I use that site all the time.
1110691
Here is something I came up with quickly ( not fully complete, I will leave that to you ! ) \n\nThis quick bit of code will give you a start ( hopefully and no recursion ).\n\nPlease note that this is not complete and you will get a memory leak in swap function ( easily fixed btw ! ).\n\n#include "stdafx.h"\n#include "stdio.h"\n#include "string.h"\n\nvoid manipulate( char* pString, int index );\nchar* swap( char* pString, int pos );\n\nchar pod[255];\n\n\nint main(int argc, char* argv[])\n{\n\n  char* p = "abc";\n  memcpy( pod, p, strlen( p ) );\n  for( int i = 0; i < strlen( p ); i ++ )\n  {\n    manipulate( pod, strlen( p ) );\n  }\n  return 0;\n}\n\n\nvoid manipulate( char* pString, int index )\n{\n  int i = 1;\n  char* p;\n  p = pString;   \n  while( index > 1 ) \n  {\n    p = swap( p, i );\n    index--;\n    i++;\n    memcpy( pod, p, strlen( pString ) );\n    printf( "%s&#92;n", p );\n  }\n}\n\nchar* swap( char* pString, int pos )\n{\n  char* p = new char[ strlen(pString) + 1 ];\n  memset( p, '&#92;0', strlen( pString ) + 1);\n  memcpy( p, pString, strlen( pString ) + 1 );\n  char temp = p[pos];\n  p[pos] = pString[pos-1];\n  p[pos-1] = temp;\n  return p;\n}
639857
use of this pointer is to show the current referemce.\nu can pass the formal arguments and variables with same name,\n\nfor eg a part of prog\n.\n.\nvoid initialize(int x,int y)\n{\nthis.x=x;//x=5\nthis.y=y;//y=6\n}\n.\nvoid main()\n{\n..\n...\ninitialize(5,6);\n}\nif this is not used the above prog will be\n\nvoid initialize(int x,int y)\n{\nx1=x;//x1=5\ny1=y;//y1=6\n}\n.\nvoid main()\n{\n..\n...\ninitialize(5,6);\n}\n\ndid u understand..
331194
Go to "MyComputer" properties.\n Then click advance tab.\nThen there u will fine "Environment Variables".\nClick on it.\nthen u will find "User variables" and "System Variables".\nTo add new variable click "New" or to modify click "Edit"\n\nUW :)
551498
I'm no "C" expert, but in Delphi this is a Windows system call, and I'm sure it will be a similar implementation in C; just alter the syntax as necessary...
1119693
I think you might need to elucidate more on that question.\n\nPerhaps you mean how do you store multiple values in a data structure.\n\nPerhaps you mean how do you modify a "final" variable. In other languages this is called a constant. The point of this is that it cannot be changed at runtime.
346423
check out http://www.planet-source-code.com - I don't do C++, but I use that site all the time, and it has great examples in source code form.
440282
in c main can return void but not in c++\nin c++ it alsways return an int
781094
Nobody is going to do your homework for you. \n\nIf you're supposed to write code examples that illustrate how two comparable programs might look, then do this. Write some simple programs in C, and then re-write the same program in C++ but put the functions your void main calls in a class and instantiate the class.
2853
I always recommend Bjarne Stroustrup's "The C++ Programming Language", third edition.  It cuts straight to the meat of what is different between C and C++ instead of messing around with arrays of char like most tutorials do.
167955
Well you can if you compile it, I forget exactly how.\n\nBut if you just have the dll I don't believe you can. It would sort of defeat the purpose if that sort of information was editable by users.
920270
Here's a start.\n\nI see you are using 'getch()' from conio.h\n\nI assume this is to insert a pause into the program?\n\nThis is not an ideal bit of coding as it is no longer supported by all compilers. Do you know that your teacher wants you to use it? (I assume this is homework?)\n\nHere's some discussion about it if you're interested\nhttp://forums.devarticles.com/c-c-help-52/c-problems-with-getch-6229.html\n\nIf you make an attempt to write some code we may be able to help you more.\n\n\n# include<iostream>\nusing namespace std;\n\nint main()\n{\n   \n  getch();\n\n   return 0;\n}\n\nNOTE: Be careful about using the answers supplied below.\nmerven uses 'void main()' which is not standard c++.\nthe other example uses some C rather than C++ in places.\n\nAnd this is from smart people who know what they are talking about and are trying to help you. No disrespect of any kind intended from me towards them. Just that what they are coding may not meet your teacher's approval (depending on her/his preferences).\n\nAre you prepared to do any work at all to help yourself and therefore help us to help you?\n\n///
886925
Yes that's a good question.\nIt's pass that value to the host program that ran it.\n\nLike if your some program executed it then the value would be passed to your program only.\nIf you ran it through MSDOS as a host then the value would be passed to MSDOS(doesn't mean it's always meaningful, for the host).\nIf the host is Windows, then the value is passed to Windows.\n\nOk......\nwith an example.......\n\n\n\nProgram : "one.cpp" : -\n\n#include<iostream.h>\n#include<process.h>\nvoid main() {\nextern int main();\ncout<<system("two.exe");\n}\n\n\n\nProgram : "two.cpp" : -\n\n#include<iostream.h>\nint main() {\nreturn 653;\n}\n\nthe program "one.cpp" should print 635. here the host program is one.cpp ..
687652
look at C++ book so many ... ^_^