~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

First of all, thanks for the sticky Mr. Dave.

Here is a list of some of the free books available on the net which should be present in the collection of each and every graphic programmer.

Free Game Programming ebooks ( general and Opengl related)

The openGL red book
http://www.opengl.org/documentation/red_book/

OpenGL programming guide
http://fly.srk.fer.hr/~unreal/theredbook/

Michael Abrash's Graphics Programming Black Book
http://public.planetmirror.com/pub/gpbb/

Waiting for the feedback of all you ppl.
Hope it helped.

Yours friend,
~s.o.s~

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I think the _fopen you are talking about is actually the inner implementation of fopen as present in stdio.h given by #define fopen(__file, __mode) __fopen((__file), -1, (FILE*)0, (__mode)) Hope it helped.
Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Error Returning a local variable

You are gettin this error since you are trying to return worker type array "w" which is local to the function and hence is destroyed when the function exits. Said simply the scope or the effect of the local variable is in the function itself since its memory is allocated in the stack of local variables which is destroyed when the function exits.

Errror size of w[] not constant

In C or C++ u cant declare an array like this i.e. an array whose size the compiler has to calculate at run time. C expects that you explicitly declare the size of the array during compile time.

Hence the acceptable options are

worker w [10];

OR

const int numberOfItems = 10;
worker w [numberOfItems];

Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Dude see the input u have given, its 41 hrs and the rate per hour is 10.

So do the simple math,

normal rate = 41 * 10 = 410

overtime = (41 - 40) * 1.5 * 10 = 15

total sal = 410 + 15 = 425

? wat else u expected.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thanks for the feedback and i would really appreaciate if everyone would post any links to resources which are useful for C programmers so that they dont have to go any further than this thread.

hollystyles commented: Nice work to the hunter/gatherer of links +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

EDIT: Please note, as I write this, the post is now 6 years old and might have some outdated information. I'd personally recommend beginners start with "Learn C the hard way" by Zed and this book since I have heard good things about them. Reading the FAQ put together by the C newsgroup folks might be a good idea.

List of free compilers and IDE

1) Codeblocks IDE integrated with MINGW compiler can be downloaded at http://www.codeblocks.org/downloads.shtml

2) Visual Studio Express Edition

3) Pelles C IDE

List of Tutorials

C programming tutorials 4th edition
http://www.iu.hio.no/~mark/CTutorial/CTutorial.html#Preface

C standard function reference
http://www.cppreference.com
http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html#Contents

Excellent site for free compilers, libraries, tutorials etc.
http://www.thefreecountry.com/documentation/onlinereferences.shtml

C programming Notes
http://www.eskimo.com/~scs/cclass/notes/sx1.html

Programming in C
http://www.scit.wlv.ac.uk/~jphb/cbook/html/

Excellent site a must see for all newbies
http://www.cprogramming.com/tutorial.html
http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/c_tutorial.html

Link to many programming tutorials
http://www.programmingtutorials.com/c.aspx
http://www.freeprogrammingresources.com/ctutor.html
http://www.tutorialized.com/tutorials/C-and-Cpp/1
http://www.techtutorials.info/cgen.html
http://www.intelligentedu.com/newly_researched_free_training/C.html
http://www.cyberdiem.com/vin/tutorials.html


Pointer and other topic specific resources
http://pweb.netcom.com/~tjensen/ptr/cpoint.htm
http://www.augustcouncil.com/~tgibson/tutorial/
http://www.newty.de/fpt/index.html

Advice and warnings for C
http://www.brainbell.com/tutors/c/Advice_and_Warnings_for_C/

Interfacing ODBC and C
http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/c_tutorial.html


- sos

Salem commented: Looking good +13
tux4life commented: Very nice :) +4
westsider123 commented: Thanks a lot! Really helpful! +0
alaa sam commented: Thanks a lot you really helped me to get started with c +0
\007 commented: Nice C guide~ +0
thendrluca commented: Usefull +0
Moschops commented: Bloodshed Dev C++ has become a bad choice in the last six years and needs removing. -2
Gribouillis commented: great thread +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I think it depends on the type of application. Java is similar to C++ in style, but you'll notice a speed difference on desktop apps right quick ;) I'd recommend going for .NET unless you're doing some huge applicaiton like photoshop or something.

Yes its true that the type of programming lang depends on the type of application to be built but developing doesnt require BIG BUCKS coz all the resources required for getting started with Java like the virtual machine, the editor, the tutorials are available in abundance on the net and that too for free.

I myself havent done development in .NET so i dont know a lot about it but the applications made in Java are cross platform compliant.

The original poster can also consider for going for Python since there are many GUI extension libraries available for free.

Hope this helps.
Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello guys this is my first attempt at learing at server side scritping language. I know basics and have worked with Javascript, HTML and CSS. Any pointers or site which can tell me or teach me the basics of ASP .NET so that in the end i can achieve the aim of building my own website or any book for beginners.

Eagerly waitign for your reply.

Thanks.

Regards,
~s.o.s~

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Where is fINPUT anywhere in your code ? It would be really better for the others to understand if you post the entire code or the module so that we can be of some help.

Hoping to hear from you.
Bye.

Regards,
~s.o.s~

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe as an attachment, when your project is finished so that a newbie can just copy and paste the code and understand its working. Of course if there are some other issues or reasons you dont want to post code then its ok.

Hoping to hear from you.

Regards,
~s.o.s~

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As for inbuilt GUI support offered by the language, JAVA would be good option and in many ways its similar to C++. Using SWINGS in java is a piece of cake and you can get a host of tuts on the net for that.

Also Python can be used for creating GUI applications by using an extension libray like PyQT which is also used by famous companies like Disney and many others.

Or maybe you can wait for other replies regarding this thing.

Hope this helps.
Bye.

Regards,
~s.o.s~

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Glad i could help, after all this is why we are all here, right. ;)

And it would be really nice if you could post your entire working code along with everything so that it would be a good reference for other ppl.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try this instead of your stuff and see if this works.

// m_strURL => ur url
 
HINTERNET hINet, hFile;
hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if ( !hINet )
{
// bail out
}
hFile = InternetOpenUrl( hINet, "m_strURL, NULL, 0, 0, 0 );
if ( hFile )
{
CHAR buffer[1024];
DWORD dwRead;
while ( InternetReadFile( hFile, buffer, 1023, &dwRead ) )
{
if ( dwRead == 0 )
     break;
buffer[dwRead] = 0;
m_strURL += buffer;
}
InternetCloseHandle( hFile );
}
InternetCloseHandle( hINet );
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It would be better if you describe the error you get or print the error report here since all of us dont have Wininet library.

Yours truly,
~s.o.s~

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Here is one of the best with some egs along with the reference to understand.

http://www.cppreference.com

Hope it helped.
Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Feels good to guide someone, but if you have doubts still now or if you dont believe wat i have said u can wait for the admins or the moderators or some other person to replly for your post.

Bye. Take care.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I dont know a lot about handling internet protocols using C++ and MFC but i think this should help you a bit.

http://www.codeguru.com/cpp/i-n/internet/generalinternet/article.php/c3411/

Waiting for your feedback.
Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

From your way of saying it looks like you want to be a generalist who wants to understand the cocepts of computing which are not dependent on any language and just understand the way things work.

I hope you have good intrest in MATHS coz every good computer science should have a healhty mathematical background.

Also you should start from understanding the baics of computing like the various number formats, how memmory is allocated, wat is segmentation etc. that is genral concepts releatd to computers.

Then you can go ahead and understand the common data structures like Stack, Queues etc. which are lang. independent and form the basic abstract data types.

To develop an algorithmic mind which concentrates more on how to solve the prob. rather than how to write the prog to solve the prob. u can start off with PYTHON.

To know how actually diffucult progg is and how to manipulate the primitive things like addressess in memory u can start off with C or C++.

Acc. to me never start off with JAVA since it makes you feel everything is so good and white in the software development world coz its so easy with all the built in classes.

Well thats to it, if u find this useful pls post ur feedback.

Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This basically depends on where you want to focus :

1) If you want to orient your thinking in the programing direction without worrying about the resistance offered by the language (which obvioulsy is a feature of C and C+++) then you would be best off starting off with PYTHON which lets you do more of thinking about the problem at hand.

2) If you want to learn a powerful language which is basically used in all fields then decide between C++ and PERL but be prepared to be lost in oblivion every now and then.

It would be better if you chose the language which influences the direction in which you want to move in your future or which is basically used for software development in your country.

Hope i didnt confuse you.

Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes you are right even i get the same output.
Maybe the behaviour of the const whose value is being modified is undefined afterall, so better not walk on the broken glass of undefined behaviour.

Well to the ppl who have come to this thread to learn somthign about constants in C and C++ maybe this can be of some help :-

http://en.wikipedia.org/wiki/Const

Hope this helped. Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There are not different values at the same memory location.

Maybe you are right but this is the output of a single run ;

The addr of the const var is 0012FEC8
The addr in ptr is 0012FEC8
The value of i is 20
The value of location pointed by ptr is 40

This is wat confuses me since you can note that both the addr are the same.

You probably compiled this with a C++ compiler, where const has a different meaning and optimization may be made that would appear to confuse you.

Yes you are right, i compiled this thing with a VC++ 8 compiler.

Does it make a difference if i would have compiled it usign a pure C compiler?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

So does this mean that the const qualified variables are placed in the CODE segment of the program rather than the normal DATA segment of the program like the array names?

So is this behaviour i.e. different values present at the same memory location different for different operating systems and different compiler designs ?

Thanks for your help. Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hell "o" to all programmers out there.
I was just fiddling around with pointers to const when i wrote this snippet.

int main (void) 
{
  int* ptr = NULL;
  const int i = 20;
  ptr = (int*) &i;
  *ptr = 40;
  printf ("\nThe addr of the const var is %p", &i);
  printf ("\nThe addr in ptr is %p", ptr);
  printf ("\nThe value of i is %d", i);
  printf ("\nThe value of location pointed by ptr is %d",   *ptr);
  getchar ();
  return 0;
}

THe problem i am facing is that the addr of the constant variable and that present in the pointer variable turns out to be the same but still when i modify the value using pointer to constant variable it raises no error. But when i try to query the value persent in the memory location pointed by the pointer and the value in the const variable it turns out to be different ???

How come the same memory location holds two different values?
Any suggestions or explanations would be gladly accepted.

Thanks to all in advance. Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Buddy you have got too many errors hanging out there in your code and even your logic is a bit wrong there.

>>>

strcpy(f[i],f[i-1]);

strcpy is used to copy contents from one character array to another. IF you just want to change the char value y not use the assignment stmt. Or do you reallly wnt to copy the character array contents? We have no way of knowing it.

>>>

void delete(int idn,int id[MAX])

delete is a reserved keyword used to free the memory block pointed by a pointer. This is a violation.

Basically i think you are confusing yourself between character and character arrays called as strings. Read some good articles so that your basics are a bit clear.

Hope it helped. Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

this just seems like it is a lot longer. but it dose the same thing. THe code that i wrote. Was any of it going in the correct direction. Or is this just another way to write the same thing. I see that you used a lot more floast and did not do any defines. ANd i also see that you did not use a while statement. Can you explain that to me.

>>> #defines are basically not used due to the bad publicity attached to it ( u can read the articles on #defines by googling for them) but again it is a matter of personal preference. Any function or progg construct performs to the fullest when in proper hands, so as far as beginners are concerned stick to using const since it makes more sense if you look at the program in a logical way.

The bottom line dont use #define as far as constant values in the program are concerned.

>>>
I didtn use a while { } loop, instead i used a do {....} while (condition); loop, since the input from the user session has to be carried out atleast once.

>>>
Also i added a bit of error checking in your code since your original code didnt check for any problems with the user input and assumed that the input was perfect.

>>>
Yes my prog in the end does wat you intended to do in your original …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes the given problem accordnig to me can be solved in three different ways :

1) Using two arrays dynamically allocated (the way which i have done)

2) Using two dimensional array dynamically allocated (the way proposed by Mr. Lerner)

3) Using an array having size (2 * Number of rows of pascal triangle) wherein we use the left part of the array to store the old pascal triangle and the right part of the triangle holding the new row of pascal triangle ( a slight variation of my method).

Hope this serves as a pointer to all the ppl who want to code pascal triangle. Thanks to all.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Please try and understand the code given below and ask if you have doubts regarding it and try to write the code once again on your own.

Maybe this is what you were looking for :

#include <stdio.h>
const float flatfeeone = 500.00; //flat rate for up to 6 credits
const float Flatfeeu = 450; //rate for undergrad rate for 6 to 12 credits
const float Flatfeeg = 750; //rate for graduate for 6 to 12 credits
const float flatunit = 250; //rate for fee per credit up to 6 credits
const float Flatunitu = 245; //rate for undergrate for 6-12 credits
const float Flatunitg = 285; //rate for graduate for 6-12 credits
const float Flatpuu = 270; //rate for undgrade for 12-18 credits
const float Flatgu = 340; //rate for graduate for 12-18 credit
const float Flatu = 5100; //rate for undgrade for 18 or more credits
const float Flatg = 6400; //rate for graduate for 18 or more credits
void clearGarbage ()
{
while ( (getchar () != '\n') || (getchar () != EOF) )
{
// clear buffer and advance
}
}
float computeGraduateTution (int credits)
{
float cost = 0;
if ( (credits > 0) && (credits <= 6) )
cost = flatfeeone + (credits * flatunit);
if ((credits > 6) && (credits <= 12))
cost = Flatfeeg + (credits *Flatunitg);
if ((credits > 12) && (credits <=18))
cost = Flatgu * credits;
if (credits > 18)
cost = Flatg;
return cost;
}
float …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

THanks to all you ppls help i finally managed to put the code together ( though using two arrays which i couldnt make to one :( )

Here is the code i am pasting here for others to have a reference.

[c]
#include "stdafx.h"
 
#include <stdio.h>

constint leftCorner = 3;
constint rightCorner = 4;
constint topElement = 2;
int *oldTriangle = 0;
int *newTriangle = 0;
void displayTriangle (int iteration)
{
if ((iteration % 2) == 1) 
{
for (int i = 1; i <= iteration; ++i)
printf ("%d ", oldTriangle[i-1]);
}
else
{
for (int i = 1; i <= iteration; ++i)
printf ("%d ", newTriangle[i-1]);
}
printf ("\n");
}
 
int buildTriangle (int tmpPascalRow)
{
int tmpRow, elementIndex;
int* src = NULL;
int* dest = NULL;
 
 
oldTriangle[0] = topElement;
displayTriangle (1);
if (tmpPascalRow == 1)
return 1;
 
newTriangle[0] = leftCorner;
newTriangle[1] = rightCorner;
displayTriangle (2);
if (tmpPascalRow == 2)
return 1;
 
for (tmpRow = 3; tmpRow <= tmpPascalRow; ++tmpRow)
{
if ((tmpRow % 2) == 1)
{
dest = oldTriangle;
src = newTriangle;
}
else
{
dest = newTriangle;
src = oldTriangle;
}
 
dest[0] = src[0];
dest[tmpRow-1] = src[tmpRow-2];
for (elementIndex = 1; elementIndex < tmpRow - 1; ++elementIndex)
{
dest[elementIndex] = src[elementIndex] + src[elementIndex - 1];
}
displayTriangle (tmpRow);
}
}
 
int main (void)
{
char inputBuffer[10];
int pascalRow = 0;
int index;
 
fputs ("Enter the number of rows required: ", stdout);
fgets (inputBuffer, sizeof (inputBuffer), stdin);
fflush (stdin);
pascalRow = atoi (inputBuffer);
newTriangle = (int*) calloc (pascalRow, sizeof (int));
oldTriangle = (int*) calloc (pascalRow, sizeof (int));
buildTriangle (pascalRow);
getchar();
return 0;
}
[/c]

THanks to all once again.

WolfPack commented: Thanks for posting the solution for others to refer. +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

what thing?

This?

3
     4  5
   4  9  5
4 13  14  5

Where the user gives the three corners, from top to bottom...

Can't you figure that out yourself?

With two arrays yes, but with one array no.
Thats y i wanted the help of you ppl.
I have even posted my effort so far in my first post but i am stuck there so plese help me out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Please can anyone help me on this thing?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hi all,

I would some help in C++ (Files) and in web design using php

Please elaborate your problem stmt since it is really very fuzzy right now.

Which help do you exactly need, in PHP or in C++?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>Here i am trying to design a custom pascal triangle where the user >can specify the TOP ELEMENT as well as both the CORNER >elements.
That's not very logical. Can you give a few examples?

Here is the eg.
3
4 5
4 9 5
4 13 14 5 ...

Though this does not exactly satisfy the rule of pascals triangle it is actually a variation of it which i saw on some web site. It stated the use of Pascal Triangle in composing music tones or something.

>Err...
>Please elaborate if possible.

Take note of the ncr function:

Dont think this would solve the hybrid pascals problem?

Pascal's triangle is boring. How about something more fractalish:

Whoa this is a beauty ! Miss Narue can you give me other such shapes to derive as execrices and where you got the problem stmt from.

Thanks a lot.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Formula for each element:

R!
--------
C!(R-C)!

Err...
Please elaborate if possible.
Thanks.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello to alll programmers out there.

Here i am trying to design a custom pascal triangle where the user can specify the TOP ELEMENT as well as both the CORNER elements.

The problem i am facing is that the prog works well till the 3rd row but starts giving rubbish values after 3rd. Looks like there is some problem with my logic. I want to do this problem using only one array and not two arrays.

Any suggestions?

#include "stdafx.h"
#include <stdio.h>
const int leftCorner = 1;
const int rightCorner = 1;
const int topElement = 1;
int *pascalTriangle = 0;
int buildTriangle (int tmpPascalRow)
{
int prev, curr, next;
int tmpRow, elementIndex = 0;
int buffer = 0;
if (tmpPascalRow == 1)
{
pascalTriangle[0] = topElement;
return 1;
}
pascalTriangle[0] = leftCorner;
pascalTriangle[1] = rightCorner;
for (tmpRow = 3; tmpRow <= tmpPascalRow; ++tmpRow)
{
pascalTriangle[0] = leftCorner;
pascalTriangle[tmpRow - 1] = rightCorner;
buffer = leftCorner;
for (elementIndex = 1; elementIndex < tmpRow - 1; ++elementIndex)
{
buffer = pascalTriangle[elementIndex]; 
pascalTriangle[elementIndex] += buffer;
}
}
}
 
int main (void)
{
char inputBuffer[10];
int pascalRow = 0;
int index;
 
fputs ("Enter the number of rows required: ", stdout);
fgets (inputBuffer, sizeof (inputBuffer), stdin);
pascalRow = atoi (inputBuffer);
pascalTriangle = (int*) calloc (pascalRow, sizeof (int));
buildTriangle (pascalRow);
for (index = 0; index < pascalRow; ++index)
printf ("%d\t", pascalTriangle[index]);
getchar();
return 0;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ok, this is what I have come up with now...my problem is that is runs consistantly during the ascending and descending part as well as can someone help me figure out how to get the highest and lowest number for a random number? i am so lost on that part, I don't even know where to look. Please someone help me!! :) I greatly appreciate anything I can get!

Thanks,
ethompson

I think you are not getting the point.

>> You were supposed to store the input in an array which u still havent done in your new code.

>> The logic or the function for findin the max and min element is not yet defined.

Anyways here is the working code.
Try to compare this code with the one you have written.
See the way the arrray has been declared to store input and the functions for sorting.

Post if any doubts in the code given and

POST YOUR CODE USING THE CODE TAGS PROVIDED PLEASE. MR. DAVE HAS GOT TIRED OF EDITING YOUR POST EACH TIME SO PLEASE UNDERSTAND AND FOLLOW THE FORUM RULES.

#include <iostream> 
#include <ctime> 
#include <cstdlib> 

using namespace std;
void bubbleSort (int randNumbers[], int count)
{
int outer, inner;
for (outer = count - 1; outer > 0; --outer)
{
for (inner = 1; inner <= outer; ++inner)
{
if (randNumbers [inner] < randNumbers[inner - 1])
{
int tmp = randNumbers [inner];
randNumbers[inner] = randNumbers[inner …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello,

I'm having some problems with trying to get my random numbers to go in ascending order and descending order as well and trying to figure out how to get when I put in a number between 2 - 25 how to get the highest number out of the random pick as well as the lowest number out of the random pick. Can someone please help!?!?!?!?! I greatly appreciate it if someone could help me out on this! :)

Below is my code I have so far...

Thanks,
ethompson

#include <iostream>                    
#include <time.h>                         
#include <stdlib.h>                      
 
using namespace std;
void bubbleSort (int Rand[]);
main()
{
     cout<<"Data Searching and Sorting!!"<<endl<<endl;
     srand(time(0));                        
 
     int Rand_Num;                         
     int Input;  
     char ans;
     int cnt, inside, outside, Swapped, tmp;
     int high, low;
do 
{
     cout << "How many numbers would you like to be generated (2 - 25): ";     
     cin >> Input;                              
     if(Input >= 2 && Input <= 25)          
     {    
          cout<<"The "<<Input<<" numbers genterated are: "<<endl;    
          for(int i = 0; i < Input; i++)    
          {
 
               Rand_Num = (rand() % 47) + 1;    
               cout <<Rand_Num<<endl;
          }
 
     }
     else
     cout<<"Sorry, that is invalid try again"<<endl;
//______________________________________________________________________________
 
     cout<<"The Highest Number is: "<<high<<endl<<endl<<endl;
     cout<<"The Lowest number is: "<<low<<endl<<endl<<endl;
//______________________________________________________________________________     
 
   void bubbleSort(int Rand, 25);
       cout<< "After sorting, the list elements are: "<<endl;
   int i;
   for (i = 0; i<25; i++)
       cout<<Rand_Num<<" ";
       cout<<endl;
 
 
 
    cout<<"Want to pick again?  ";
    cin>>ans;
    cout<<endl<<endl;
}
   while((ans=='y') || (ans=='Y'));       
 
cin.get();
cin.get();
return 0;
}

There are a lot of problems in your code. To begin with :

…
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The same program works fine with me.
Which OS and compiler (version) are u using?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, thats it even i tried it.
Good one dave

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Write the error to a text log file before exiting ?

Yes good idea but it only solves the prob of displaying the error msg and not the prob of the screen staying so that i can see the output.

Your idea can be extended to displaying the output also in the log file
which is saved in HTML format like the VC IDE log files.

Change environment -- run it from the command line.

Sorry but i didnt understand this solution since never worked with command line compilers. If poss can u elaboreate on this. Thanks a lot.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The "need" to pause is a symptom of the environment from which the program is run. And in cases in which you exit , you can also write code to pause there. The point is that you're missing the point.

Maybe yes, thats why i explained in the previous post the dilemma i was facing.

Programs that have memory allocation in the code require the system to bail out in case of in case of some problem.

Since i used exit(1) i needed system("pause") to stop the console screen to see the output.

Do you know any way in which the prog can bail out when some error occurs without the use of exit (1) ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I think this prog solves the prob of both the original poster and Mr. Dilip. Hope this helps. If any portability prob or any other prob in the code then let me know.

#include <stdio.h>
#include <ctype.h>
int main()
{
char a[26];
int i;
printf("Enter the string: ");
fgets(a, 100, stdin); // safer than scanf()
i = 0;
while (a[i] && isalpha(a[i])) // check input is alphabet
{
if (isupper(a[i]))
a[i] = tolower(a[i]); // is this wat the OP wanted?
// no need to check bounds due to the nature of the prob stmt
if ((a[i] >= 'a') && (a[i] <= 'm')) 
{
a[i] += 13; 
}
// to other check req as this will always be greter than 'm' and less than equal to 'z'
else 
{
a[i] -= 13;
}
a[i] = toupper(a[i]); // is this wat the OP wanted?
i++; 
} 
fputs(a, stdout);
getchar();
return 0;
}

See ya.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I didnt know sarcasm was allowed outside Geek's Lounge :-)

Well getting back to the topic, there are some cases where u just cant stop the console window from disappearing without the use of system ("pause") (just wanted to let u know that i have read the disdvantages of system function provided in the above thread).

Take for example a prog. that has many exit (0) and exit (1) calls to duck out in case of some failure like mem. allocation failure. In this case the calls to getchar () and cin.get() placed at the end of the program just wont happen since the exit (int) has already taken place.

So other than system("pause") do you know any other way the console screen can be stopped?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, a more vulnerable and less portable solution is always better than a safe, portable one.
:lol: :rolleyes:

I dont get you, is this sarcasm?

I thought since he needed the pause without the cin.get() maybe this function would help.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

lol maybe this is what you are looking for

system("pause");

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe the below link can solve the problem of stray "\n". Hope it helped.

http://www.daniweb.com/tutorials/tutorial45806.html

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello to all developers out there.

Just wanted to know if i can embedd my existing VB application in a browser window so that when the link is loaded the application runs and accepts the input from the user.

If it is possible i would really be grateful if you could provide me the small code to do so, as i have weak web design and coding basics.

Thanks in advance for your help, see you.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Good game for a beginner, carry on.
Have u ever considered writing the game using a external game library. Seeing your enthusiasm for making games and your game, i would very much recommed you to move out to core C++ and start making games.

If you ever need any help reagrding any game libraries just post in this thread and i will point you to them and even give you a lowdown on the game development scenario.

And by the way, the game crashes after the player loses all his life. ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Call the function as

pointTo (&ptr, text);

Is it because the function accepts double pointer ie ptr to the ptr and hence to make the ptr "scr" the link to the modifiable char pointer "ptr" we are passing the address of the ptr variable.

If not then can you please explain your logic regardin the above change.

And btw i have checked the links and they are real good with a pdf file of 53 pages just on pointer introduction. Thanks a lot. You rock man.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you want to change a value in a called function, you need to pass a pointer to the value. If what you want to change is a pointer, you need to pass a pointer to the pointer.

Hmm i think i am getting a bit of wat you are trying to say.
So i think i need to redefine the function as void pointTo (char** src, char* dest) and should call the fucntion as pointTo (ptr, text); Is this thing right?
It would we very kind of you to tell me some links where you got your pointer concepts cleared from and which explains pointers from ground up to the professional level.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello all prorgammers out there.
While just fiddling with the pointer concept of mine which is weak i wrote a very simple function to just give the addr of the array to the char type pointer so that i can refer the array using the pointer instead of the array name.

void pointTo(char* src, char* dst);
 
int main() {

 char text[3] = {0}; // create a array with all elements 0
 char* ptr = 0;        // the char pointer which should refer the array
 
 printf("\nThe addr in text is %p", text); // for debug
 printf("\nThe addr in ptr is %p", ptr); // for debug
 
// here we pass the char pointer as first argument and the array 
// pointer ie the addr pointed by array as second arg.
 
 pointTo(ptr, text);  // actual funtion call
 
 printf("\nThe addr in text after function is %p", text);
 printf("\nThe addr in ptr after function is %p", ptr);

 ptr[0] = 'A';  // change using pointer instead of array name
 ptr[1] = '\0';
 
 printf("%s",text);  // print the output
 
 return 0;
}
 
// attempts to asssign the addr in destination to the addr in 
// the source so that we can manipulate the array
 
 
void pointTo(char* src, char* dst) {
 src = dst; 
}

But this code jumps out as soon as i execute it.

My pointer concepts are a bit weak so can you point me to links which explain them in full depth and all that is required to tame them.