ssharish2005 62 Posting Whiz in Training

Until you indent you i dont think your going to get any help from here. Indent you code. I can’t compile this code as the code will never compiler. Python is strictly indent specific. I suppose you should know that by now. Indent your code and post again!

ssharish

ssharish2005 62 Posting Whiz in Training

I've never Django before, but straight getting into web develpment uisng some API would be off starting from far up than from the basics. I would suggest you to have a look on some tutorials on html create a few simple web pages and then try do some CGI scripting using Python and then you could get into using API's. Not sure how good you are on Python.

ssharish

ssharish2005 62 Posting Whiz in Training

>delete [] pArr;
Thats is to delete an array of node. Not to delete just a node. Atleast from OP context.

Please stop posting C++ code on C forum.

-ssharish

ssharish2005 62 Posting Whiz in Training
while((sizeof(struct player)) > 1)
{ 
      for (j=0; j<k;j++)
      {   /*count k-1 places around circle*/   
           current_player = current_player->next; 
      }

I dont really understand the logic here? Thats is gonna get into an infinite loop! You need to have a proper condition for while to exit.

-ssharish

ssharish2005 62 Posting Whiz in Training

And also this line is gonna print junk

printf( "\nInteger decomposition of %d is %d + %d + %d\n\n", n, a, b, c ) ;

You might to return those i,j,k values back to main to print them accordingly.
-ssharish

ssharish2005 62 Posting Whiz in Training

Well I got to see how you call DeleteNode function. Is the node parameter to the DeleteNode function is a valid pointer to a strcut node?

And in the Init function you create a new Person node and do you assign that it some other struct anywhere?

And by the way heck do you want to mix up with all C & C++ code. Your just violating the standard!

-ssharish

ssharish2005 62 Posting Whiz in Training

This is quite messy; you might have start looking at some text on good programming practice. The few things which I could pick up from a quick glance are as follow

1. Main should return an int not void – MUST
2. Do not declare function within main. Would still work not a good programming practice. You just limiting the scope of those function visibility to main function. In long run of programming C you would seem what I’m saying.
3. new1 is a variable of type linked_list but you haven’t declared it anywhere
4. And you use new1 variable at few places, but really it cant be accessed anywhere apart from create_node function. You see why?

-ssharish

ssharish2005 62 Posting Whiz in Training

'.' is the operatir which you are looking at.
'->' is the operator which you need when you dereference the struct pointer variable.

Like for an example

struct node
{
    int data;
}

struct node *d;
struct node d1;

printf("%d\n", d->data); // you could also use (*d).data here. The reason for this is operator precedences
printf("%d\n", d1.data);

~ssharish

Salem commented: 2.5 YEARS late, what exactly have you added here? Nothing on-topic. -3
ssharish2005 62 Posting Whiz in Training

As everyone else had pointed out solution for, it better to you scanf function to read string or to reading anything at all. At least that my preference. But anyway, if you still used it make sure you flush the input stream before the second call of scanf function. The following code would help you in flushing the input buffer

void clear_buffer( void )
{
     int ch;
     
     while( ( ch = getchar() ) != '\n' && ch != EOF );
}

~ssharish

ssharish2005 62 Posting Whiz in Training

>regardless of whatever stores at a shouldn't it produce -2.
I dont really see why do you expect those values. When you dereference a, you will get junk jusy because you haven't initialised it. When you didthis *(a+1), it was getting the address of a thats the base address and the adding one to it. It other words its called relative addressing. The point a itself is not moved to a+1.

Try initialising a values and try it back again like as follow

#define print(x) printf(#x"=%d\n",x)

int main()
{
        int a[10];
        a[0] = 10;
        
        print(a);
        print(*a);
        print((*a)+1);
        print((*a)+3);
        print((*a)+1-(*a)+3);
        
        getchar();
        return 0;
}

~ssharish

ssharish2005 62 Posting Whiz in Training

I would agree with AC, it is a crappy code, which dosnt follow any standard. If you still say that a valid code, then have a look at this

MyLL     * first;    MyLL     * last;

What is MyLL. Is it typedef ? No!

~ssharish

ssharish2005 62 Posting Whiz in Training

You could also do something like this. Where you return the memory address of the allocate space in heap.

#include <stdio.h>

int** allocate_matrix(int rows, int columns);

int main() 
{  
    int **table = NULL;  
    
    table = (int **)allocate_matrix(3, 3);  
    
    getchar();
    return 0;
}

int** allocate_matrix(int rows, int columns) 
{
     int i, **table;
     
     table = malloc(rows * sizeof(int *) );
  
     for (i = 0; i < rows; i++) 
         table[i] = malloc(columns * sizeof(int));
         
     return table;
}

And of course, dont forget to do some error checking there! Which is very important

~ssharish

ssharish2005 62 Posting Whiz in Training

Well, there are certain ranges that the bluetooth can cover according to the standard. There are two type class1 (covering 100m) and class 2(covering 10m). I suppose you can try experiment those range as you keep moving away.

well, increasing the range of the bluetooth is possible and the Bluetooth SIG is already working on it. There are many standards that you will have to follow. The new version of the standard is released you program your bluetooth according to the standard, unless you invented your own standards!

OK, do you know what API have you been using to program your bluetooth?

-ssharish

ssharish2005 62 Posting Whiz in Training

I HAVE A VERY PECULIAR PROBLEM,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,


THE PROGRAMS I COMPILE SHUT DOWN AFTER COMPILING ONCE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

FOR EG-
I CREATED THIS PROGRAM FOR GETTING THE ASCII CODES OF AN ALPHABET ,,,,,,,,,,,,,,,,,,
AFTER I WROTE THE ALPHABET IN DOS IT DISPLAYED ITS VALUE AND SHUTDOWN,,,,,,,,,,,,,,,,
HOW CAN I ALTER MY PROGRAM TO TAKE IN AS MANY VALUES AS I WANT????????????????????????????????

#include<stdio.h>
#include<conio.h>


main()
{
char a;
clrscr();
printf("enter any character\n");
scanf("%c",&a);
printf("the ascii code of %c is %d",a,a);
getch();
}

THANK YOU,,,,,,,,,,,,,,,,,,,,,

Well, that because you used the scanf function to read the value. The quick solution for this is to place two getch or getchar()! Or you will have to call the following function just above the getch() function or everything you read a char you will have to call this function before you read. That makes sure that the input buffer is clear and program won't shutdown!

void clear_buffer( void )
{
     int ch;
     while( ( ch = getchar() ) != '\n' && ch != EOF );
}

-ssharish

ssharish2005 62 Posting Whiz in Training

Ok, this looks a bit more sensible. So as you can see that you don’t have to read anything from the first two lines of the file. You really need to extract the information from the third line.

Follow the steps given bellow:
1. Open the file
2. Read the first 2 lines and discard
3. Start buffering the data from thrid line onward and start extracting the data from the buffer using fscanf or the (fgets + sscanf).
4. And store then in a data structure.

If you can get to this point, I will give more instructions! By the way the code you have posted has a very horrible indentation. I refused to look at it. Indent the code and repost it back again.

-ssharish

ssharish2005 62 Posting Whiz in Training

Well, it donst make any sense of the input file that your trying to read with regards to the student grade information. If I was you, i would go your lecture and speak about on how the input file should be read. And how the file had been formatted with reference to the student grade information.

If you know that, then it makes it ease to read the chucks of the file where each chuck would be the information about one student!

-ssharish

ssharish2005 62 Posting Whiz in Training

>how do i save the c programs i compiled on borland c++ on the dekstop???????????????????????
Well, when you compile the C code you would the binary or the .exe file out of it. Unless you have any errors. Assuming that your program compiled with no warning or errors, the .exe file should be in you local working directory. If you want to save the binary of it on the desktop then i guess you will have to look at the compile command line options and look for an flag output.

Just made a quick search, it’s the -n flag that you would have to use. That is

bcc<x> -n <output dir path> <source file>

<output dir path> Please see AD post.

-ssharish

ssharish2005 62 Posting Whiz in Training

Hi,
I am trying to develop a DOS-like system which will be able to do all minor functions like cd.. cd/ and changing to sub directories.

Guys I am stuck in how to find a single path for many files.....

Thanx in ADVANCE

Well, if you are trying to executing those DOS command through your code. The only piece of work which you will have to do is to format the command and then look at the directory structure and then pass the formatted command to the system function. That should probably simulate all the simple commands that you want.

But then again, if your using the system function you haven't really achieved of anything writing your version of Windows DOS!

-ssharish

ssharish2005 62 Posting Whiz in Training
/[.].*\(15\).*\(53\).*\(92\).*\(=>\)

This would still wouldn't give you the right answer? Its expecting all the search charcters to be in the same line. Look at nucleon post.

-ssharish

ssharish2005 62 Posting Whiz in Training

>My question is: If i'm the customer, how can i edit the quantity shown on the overview so that i can afford to pay the totalprice(if i've ordered too much) and delete some on the overview if i want to delete it(really short on money).

Well, you can display all your menu with the corresponding values next to it. And at the bottom of the above menu you could have one more horizon menu with the C-Calculate, D-Delete etc etc. This would allow the user to edit the qty value and to re-calculate the price press ‘C’ and that your probably clear the screen the then display the new value or the updated value. Or you don’t have to clear the screen. Perhaps, just update the value at the x & y position. Since, they are more fixed in your case.

>And if i'm the owner of my meatshop, how can i see what products have been sold and the quantity?
Well, if you wanted to use files handling, then probably you will have to record all the details of qty and the total price for each transaction. Its up to you on how do you want to write them onto the file.

1. Place them in the structure and then write the structure.
2. You could store them in a variable and then write the variable to the file.

If you want to know more about the file handling google file handling in …

ssharish2005 62 Posting Whiz in Training

>Please suggest the addValue definition to accommodate this change
Looking at the way you call the function. The function definition should look like:

void addValue(struct Info **info, char *value, int posVal);

So that's the function addValue which takes pointer-to-pointer of struct Info type, char pointer and an integer.

This would eliminate the requirement of returning the struct Info * from your addValue. If that makes sense!

NB: Please use the code tags. It makes it more readable and perhaps you can get more help.

-ssharish

ssharish2005 62 Posting Whiz in Training

filetype = ????;

So if the flag matches, you can get the argument by the global variable optarg. That should hold pointer to the argument which you are looking for!

filetype = optarg;

ssharish

ssharish2005 62 Posting Whiz in Training

Look at the ncurser library, that should give much control the console window. So that you could move your cursor around to locate the value on the screen.

I assume your working on Linux/UNIX platform ;)

ssharish

ssharish2005 62 Posting Whiz in Training

Use sprintf function to convert int to string. Thats the more portable way of doing it. Since itoa is not portable!

char *cvtInt( char *str, int num)
{
    sprintf( str, "%d", num );
}

ssharish

ssharish2005 62 Posting Whiz in Training

# include <stdio.h> is an "Unresolved inclusion"

Have a look at this thread, should be the same problem your facing as well. The GCC should have been confused on where the include files are located. I would really guess it shouldn't. but its worth a try!

ssharish

ssharish2005 62 Posting Whiz in Training

Here is a link which could give you some hint!!!

ssharish

ssharish2005 62 Posting Whiz in Training

I have seen "good advices" to read stdin char by char until '\n' or EOF occured. I think, it's a bad idea: there are situations when user/program dialog hangs.

Thats the only way which i can think off, which could be portable to certain extent. But as you say if it was used in some event driven cases then probably it might hang (Need to hit enter, since getchar is used!), if '\n' or EOF not found in the input buffer.

ssharish

ssharish2005 62 Posting Whiz in Training

t=(NODE *)malloc(sizeof(NODE));

Why the hell would you cast the malloc. You shouldn't do that! Read this.

@OP for me most of of the things seems to be fine, except the head node pointer deferenceing like it has been mentioned by others already. Unless you've got your head node like this

void Insert( NODE **h, data );

???

ssharish

ssharish2005 62 Posting Whiz in Training

Hi frnds,
i have been programming for abt a yr now n used to consider myself gud wid c programming until i chked out this forum....

Huh???

If you been programming for an year and you seem to consider a good programmer. But still you are not that confident enough!!! I would say go engae youself with some personal project and if you are stuck at some point post those question here. We might be able to help!

EDIT: By the way, dont use sms text in the form. Learn to be more professional by typing in the some complete word!

ssharish

ssharish2005 62 Posting Whiz in Training

Hi ArkM,
How else can we clear the input stream?... I think the issue with the above code is basically the input stream is not cleared... I also read that the usage of fflush for stdin is undefined...


Regards,
Ahamed

Use this instead

void clrInputBuf( void )
{
     int ch;
     
     while( ( ch = getchar() ) != '\n' && ch != EOF );
}

ssharish

ssharish2005 62 Posting Whiz in Training

Isn't negative factorial kind of wrong altogether?

YES it is :) Perhaps the OP should check the value of n, before sending the value to the fact function.

print "Value for n ?"
   read n

if( n >= 1 )
   print fact( n )
else
  Error

ssharish

ssharish2005 62 Posting Whiz in Training

how could I add something to the function so it calculates when and if n is negative

Well, you got to be pretty careful on what your placing in the recursive function. The function is built to find the factorial for a given number. Tell me what are you trying to achieve.

Why do you want to check for n is negative??

if( n < 0 ) {   ...   }

This should check for the negative function. You could perhaps replace the statment in your fact function and see what output you get. I would guess not the right answer your looking for!

ssharish

ssharish2005 62 Posting Whiz in Training

Well there are few thing which you need to consider. First of all the function name is not write. In you code you have declared a function prototype clearly, but why dosn;t that reflect in your function definiation.

Your function name is return1 which should be return1. And then within the function your should check for n <= 0 not 1 or n == 0 . And also if thats true you should return 1 not return1 . Give a space between return and 1.

ssharish

ssharish2005 62 Posting Whiz in Training
int return1 (int n);

Why is that semicolon there??? Delete that! Syntax error

ssharish

ssharish2005 62 Posting Whiz in Training

Perhaps you should make an effort to search on the form. There might be like tons of results on this issues. But here is the pesudo code.

<return type of int> function name FACT ( taking int as an argument )
{
   if n equals to zero
      return one;
   else
       return n multiple FACT ( n minus one );
}

NB: Learn to start using code tags!

ssharish

ssharish2005 62 Posting Whiz in Training

As I can see, you are calculating the X axies values right, but not the Y axies values. Which dont incrment the values a bit more in the Y axies values to suit your requirnment. The following is the bit og your code which you need to cocentrate on

for(d=2;d<=nod;d++)
   {
   if(cnt%7==0)
     {
	y++;
	cnt=0;
	x=x1-4;
      }
      x = x+4;
      cnt++;
      gotoxy(x,y);
      printf("%02d",d);
   }

ssharish

ssharish2005 62 Posting Whiz in Training

Hey guys, finally got my passport delivered as well. So I am all ready to start my work. Heh heh.

This thread can be now closed with plenty of JOY :)

ssharish

ssharish2005 62 Posting Whiz in Training

Heyyyyy I got a JOB. I did came to know like a 2 week ago. I should have posted it down here.

Bu, I still cant close this thread. Since i cant start the work until I get my passport from the Home Office. I get that, I am gonna start work. :)

Hope to get my passport very soon. But end of this month.

ssharish

ssharish2005 62 Posting Whiz in Training

Hmmm seems like that need to implement a lexical and a syntax analyzer. Have a look at compiler design concept.

ssharish

ssharish2005 62 Posting Whiz in Training

hehe cheers ArkM :)

ssharish

ssharish2005 62 Posting Whiz in Training

Well, algorithm can be implemeneted in any language, its just not in C++. I have implemented the same algorithm in 3 different languages. Follow the link to find the way to convert http://scriptasylum.com/tutorials/infix_postfix/algorithms/infix-postfix/index.htm

using stack machine.

ssharish

ssharish2005 62 Posting Whiz in Training

HAHA what is Ant Clustering algorithm. Never heard of it before. But any way, no one is gonna give you the code unfortunately. People are here to help but not to pass on the code. Have you go any work on this algorithm that you on done? Post them here.

ssharish

ssharish2005 62 Posting Whiz in Training

What I can understand, is that your are looking for something called Infix to postfix expression. And then solve or evaluate the postfix expression. The postfix expression can be evaluated very easily using a stack machine. Have a go researching on Postfix evaluation algorithm. Thats should probably get you in the right direction.

ssharish

ssharish2005 62 Posting Whiz in Training

You dont have to have such a huge list if and else to do this. You to reduce that to just few lines of code. Looks the my version of convert function.

int convert( char *str, int *number )
{
     int i;
     
     for( i=0; str[i] != '\0'; i++ )
         if( isalpha( str[i] ) )
             number[i] = (str[i] - '0') - 7;
         else
             number[i] = (str[i] - '0');
         
     return i;
}
/* my output
my input - char str[] = "123456789ABCDEF";

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
*/

ssharish

ssharish2005 62 Posting Whiz in Training

It looks like that he might have his own SDL and API by the looks of it.

@OP - What does this code do?

ssharish

ssharish2005 62 Posting Whiz in Training
scanf("%d", &miles);

You need to read double here. But you are reading integer. Or at least change the type of miles here to integer. You might actually expect some meaningful result.

And you have an infinite loop in your code. Your program will keep requesting for miles every time. It donst even come of loop. Since you read gall ,just once and miles every time. Perhaps you should change the while condition to check miles != -1 .

ssharish

ssharish2005 62 Posting Whiz in Training

Hello all,

Can any one explain me whats the main different between them two data structures. I have been like working on them quite lot now. When do we use tuples and when do we use list. Any specific explains are much appreciated.

Thanks a lot

ssharish

ssharish2005 62 Posting Whiz in Training

thanks man. we use pic18 serials. I get c complier which is picc and ide mplap from the company. I never have experience on embedded programming and chip things. so is there any hints or resourse could help me get start?

Well, if you don't have any experience of working on embedded programming. You should start get some book on PIC controller and learn. Embedded programming is something different programming paradigm compared to normal programming. You are limited to so many and you got achieve your solution with those boundaries. I would personally think you need to buy so good book on PIC. Most probably the book would more concentrating on a single board. I mean the author would choose a board and he goes thought it through the book. One if you can get hold on the terminologies and techniques you should be fine in programming any other controller, provided you have the schematic and the Manuel for that board!! :)

ssharish

ssharish2005 62 Posting Whiz in Training

Brizhou, Is that all have you got so far. The was a poor attempt. And where is your code tag. No one of gonna ook at your took.

Let me ask, have you understood the question throughly? If not you need to sit down and look at it and make sure you understand what they are really expecting from you.

ssharish

ssharish2005 62 Posting Whiz in Training

The only thing which you need to work around is to find the no of digit after the decimal point. If you can get the no of digits you could pow function to get the denominator and the numerator would be just the original number with no decimal point in it.

ssharish