ssharish2005 62 Posting Whiz in Training

In addition to what Ancient Dragon said, YES java can be used to program some low level devices. As far I know it is quite used in the mobile programming and in Bluetooth and many others. Well what you need to understand here is the fact that they are all running on a specific platform. You write a program using java for a mobile device and the program get compile to generate a bytecode which is then interpreted by the Java Virtual Machine (JVM). You can clearly see that the target device should be installed with the JVM, which it does on most devices.

Now, let’s think it practically with the ATMEL AVR board. These boards come with the AVR microcontroller which has a very small amount of memory. We are speaking in KB’s. We use several techniques to improve the efficiency of the code to make use of the memory effectively. When it comes to ATMEL we are speaking of three types of memory flash, SRAM, eeprom.

The ATML AVR board doesn’t come with any RTX or RTOS with it. The only software which gets shipped is the boot loader. It doesn’t come with JVM. The JVM its self needs a specific platform to run which the AVR doesn’t support (I might be wrong).

And more over java doesn’t support pointers, and for programming an embedded system you need pointer. Since I don’t program java I am not pretty sure about it. I think its some …

Ancient Dragon commented: Very nice explaination :) +32
ssharish2005 62 Posting Whiz in Training

oh oooooooooo, what is it now???

ssharish

ssharish2005 62 Posting Whiz in Training

arrrr why don't you search on the web, there are tutorials which you could explain everything. Well, what happened to your library books. But i thought i will nice to you today :). So here are some link which i thought is more reasonable

Break and Continue
Return

ssharish

ssharish2005 62 Posting Whiz in Training

Well done, you did get how to calculate square and cude. You learn new everyday!

ssharish

ssharish2005 62 Posting Whiz in Training

You indentation is OK but not perfect. You present your code in a good way, .you expect can expect more help. Take me an example I totally ignored your post when I just looked at your at start. I had a look at it again. This applied to all newbies. But i have sorted it out for now.

#include "systems.h"   
 
int mystrcmp(const char *tag, char *buff) 
{
  int l = strlen(tag) ;

  return( strcmp(tag, buff, l) ) ; 
}

int params( const char *file, int *nx,  int *ny ) 
{
  FILE *fd ;
  char buff[256];

  fd = fopen(file,"r") ;
  
  if ( fd == NULL ) 
  {
      fprintf(stderr, "cannot open %-s\n",file) ;
      return 1;
  }

  while ( fgets(buff,256, fd ) )   
  {
      if ( mystrcmp("nx", buff) == 0 ) 
	     sscanf(buff, "%*s %d", nx );   
      
      if ( mystrcmp("ny", buff) == 0 ) 
	     sscanf(buff, "%*s %d", ny );
   }
   
   fclose(fd) ; // This part of the code should be outside the loop.
   return 0 ;
}

I have changed few thing in your code. So that the clarify of your code improves. Perhaps the code which is highlighted in blue was must ;).

ssharish

ssharish2005 62 Posting Whiz in Training

Write a program that uses pointers to type double variables to accept 10 numbers from the user, sort them, and print them to the screen.

This is pretty tricky. The question says "pointers to type double variable", but it don't anywhere say "pointers to type double array. Which is what is this

double *n[];

That is totally wrong. That a pointer to a pointer. Well let me give you an example. With the above notation what you could do is this

double arr1[] = { 20.5, 3.6, 452.3, 6.2, 4.25 };
double arr2[] = { 40.5, 3.5, 42.3, 6.2006, 45.25 };
       
double *array[10];

array[0] = arr1;
array[1] = arr2;
.
.

As you can the each elements of array hold an starting address of an array of doubles. If you are trying to sort that sort of an array its completely a different approach. You got to do more than what sort methods you have followed. You should consult your professor to make sure what he is expecting.

Well, at least i understand that from the question. Please correct if am wrong.

ssharish.

ssharish2005 62 Posting Whiz in Training

haha he really expecting us to do his work. nana ;) you can't do that here my friend. Narue has already shown in here sample code on her previous post. You wouldn't believe its just a 2 line of code.

Narue with your permission i gonna pinch your code.

for ( n = 1; n < 10; n += 2 )  
     printf ( "%d\t%d\n", n, n + 1 );

How would you calculate square n * n --- OK
How would you calculate cube n * n * n --- OK

If you expect more than that, god help you.

ssharish

ssharish2005 62 Posting Whiz in Training

Pleaseeeeeeeeeeeeeeeeee use code tags :'( and intendant the code.

ssharish

Salem commented: I hear that! +18
ssharish2005 62 Posting Whiz in Training

LOL you've opened a thread which is like two years old now. The OP might have already solved this problem by now.

Perhaps, he might have got a far better knowledge than what he had when he started this thread. And you post what information does it gives him anyway???? Try to explain things a bit more clear!!

ssharish

ssharish2005 62 Posting Whiz in Training
int main()
{
     tree Tree;
     char foo[2]; 

     foo[0] = 'b';
     foo[1] = '\0';
     Tree = NULL;

     add_name( &Tree, foo );
     print_tree( Tree );
      
     getchar();
     return 0;
}

Thats how my main is constructed and my output:

b = 0.000

ssharish

ssharish2005 62 Posting Whiz in Training
char foo[1];

Change that to

char foo[2];

I dunno what happenes there, but that works.

And always typedef the struct after it has bas been defined. And intialise the tree pointer at main to NULL before you send that the function add_name. That is must. You have been lucky in this case, otherwise the you would have ended wiitht some SF with the broken code.

struct _node
{
    char *name;
	double val;
	struct _node *left;
	struct _node *right;
};
	
typedef struct _node *tree;

IN MAIN

tree *Tree
Tree = NULL;

ssharish

ssharish2005 62 Posting Whiz in Training

hmm this is the first time i am looking at a different way of allocating a 3D array. But referecing the elements within that is something really interesting. This is how i use to follow

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int ***array;
    int i, j;
    
    if( ( array = malloc( sizeof( int **) * 10 ) ) != NULL )
    {
        for( i =0; i < 10; i++ )
        {
             if( ( array[i] = malloc( sizeof( int * ) * 10 ) ) != NULL )
             {
                 for( j = 0; j < 10 ; j++ )
                 {
                      if( ( array[i][j] = malloc( sizeof( int ) * 10 ) ) != NULL ) 
                          printf("a[ %d ][ %d ] allocated\n", i, j);
                 }
             }
        }
    }
    
    for( i = 0; i < 10; i++ )
         for( j = 0; j < 10; j++ )
              free( array[i][j] );
               
    for( i = 0; i < 10; i++ )
         free( array[i] );
    
    free( array );
    
    getchar();
    return 0;
}

ssharish

ssharish2005 62 Posting Whiz in Training

I don't really see a great importance of this code here

int chxvar = 1 << (8 * sizeof(int) - 1);

any explanations???

ssharish

ssharish2005 62 Posting Whiz in Training

Hey singal.mayank, well what i can see is that you know what you want, but why don't you try implement them. You know that sentence can be delimited by the multiple chars. . ! and there are many other which need to considered as well.

Jeph has already give an function which can tokenise the string. May be you should see if the following helps you out.

1. Make a list of char which can deliminate a sentence
2. Use a string tokeniser function to find if there are any above list of deliminator char
3. If so token the string and store them in a buffer or print as you where doing

An alternative solution for strtok is to use fgets and ssanf functions, which i personal prefer use them.

ssharish

ssharish2005 62 Posting Whiz in Training

Haha, OK i will give you an hint but not the answer. So relational operator should be used. But they dint say that cant use arithmetically operator did they???? Is that more than enough to give you a hint.

ssharish

ssharish2005 62 Posting Whiz in Training

Have you already installed in Windows XP on your machine. Or is this the first windows installation.

Becase you will have consider lot many things when installing lower version of windows on to latest version. Its normally the other way around.

ssharish

ssharish2005 62 Posting Whiz in Training

Well, it does make any difference in assiging the a string to a char pointer. What I really wonder is how is that killing your processor. Is there any loops which goes to an infinite loop? Or there may be some problems with the implemenation of that function may be. What does your application do?

ssharish

ssharish2005 62 Posting Whiz in Training

May be, if you had reseted the router recently would have rolled back some default setting which might have changed the router setting :-/

ssharish

ssharish2005 62 Posting Whiz in Training

Ehhh thats really strange, you changed ti PPoE, PPoE is basically used to conenct to the ISP Radius server from the router. OK are you on ADL or cable network. Hopefully you should have got those username and password details from your ISP

ssharish

ssharish2005 62 Posting Whiz in Training

How about the firewall and stuff. Have you got any firewall installed on your machine. Are you able to access the router setting page? Where did you run the nslookup comamnd; was it on your desktop machine or the laptop? Have you every connected to the internet through your laptop before to the current ISP network?

I dont think it is anything to with your ISP. Since its a ADSL + the router is of your own, they wont able to give you much support.

ssharish

ssharish2005 62 Posting Whiz in Training

why the hell would you require jerusalem-frere.2 file. You know its a DOS virus. And on top you expect us to post that code down here and get polluted.

ssharish

ssharish2005 62 Posting Whiz in Training

What do you mean by linking here?
Are you trying to run a different program with a program and are you trying to access the a website.

If you you could use sockets to access the websites.

ssharish

ssharish2005 62 Posting Whiz in Training

May be you should be looking for something like this

from string     import split, lower
import os, string

strOriginal = "God Godess Brother Sister Family"
strFinal = []

strTofind = raw_input("Enter a word ot search")

for token in split(strOriginal, " "):
    if string.find(lower(token), strTofind) != -1:
        strFinal.append(token)

print "The final string"
print strFinal

##my output
##The final string
##['God', 'Godess']

NOTE: Use code tags always (code=python) <place your code here> (code)

ssharish

ssharish2005 62 Posting Whiz in Training

Well I really suspect it could be the DNS in your case. The wireless router is get you the DNS. Ok the better idea is to find out the DNS server address and the configure it manully. But before you do that try pinging to this address "64.233.187.99" and see if you can find that addess. That the google IP address.

If you see that you get replies that its your DNS i am pretty sure. Check you DNS server from the machine which you have conencted wiured and internet is active through using nslookup command.

And manully configure that on your laptop. See what happenes there. Let us know how you get along!

ssharish

ssharish2005 62 Posting Whiz in Training

Well what trouble is it your getting. You got to gives more information, ot get more help. Do you get any error message and anything which isn't right there?

ssharish

ssharish2005 62 Posting Whiz in Training

Ok what installer is it. Are you trying to install VB6.0? You can get visual studio express edition for free. Why not install that.

What programming language are familiar with?

By the way, welcome to daniweb.

ssharish

ssharish2005 62 Posting Whiz in Training

Well I the current pointer was in main. But it was in a different function and that’s fine. Look at Dave’s post as well. He pick the interesting part. Let your type def be after the struct declaration. And you cant have the same identifiers defined in the type def.

struct GROUP
{
	struct GROUP *__parent;
    struct GROUP *cats;
	char *typeID;
	unsigned long remainingSize;
	char *groupID;
	int nCats;
	struct GROUP *lists;
	int nLists;
	struct GROUP *props;
	int nProps;
	struct GROUP *forms;
	int nForms;
	struct CHUNK *chunks;
	int nChunks;
	
};
typedef struct GROUP *GROU;
typedef struct CHUNK *CHUNK;

Now change all the GROUP references to GROU. And should get ride of quite a lot of error for you.

Ssharish.

ssharish2005 62 Posting Whiz in Training

what i can see here is that you mobo might be with some problem. From what your saying. but not really very sure.

Well what does the hard driver motor starts up when you boot your machine?

Check all other componets from your this machine with the different machine and see if it work and then come to a conclusion wheter it as mobo problem.

ssharish

ssharish2005 62 Posting Whiz in Training

Have a look at a function calle3d fgets which is defined under stdio.h library. This function will do what excatly you want. It read a line of text from the text file until it EOF which then return NULL. The sample usage of that function can be found bellow

FILE *fp;
char buffer[BUFSIZ];

if( ( fp = fopen( <filename>, "r") ) != NULL )
{
    while( fgets( buffer, BUFSIZ, fp) != NULL )
           printf( "%s", buffer );
           /* You could backup this buffer
              by copying it on to a different
              char array */
}

ssharish

jephthah commented: simple +4
ssharish2005 62 Posting Whiz in Training

cstring.h (C++; should be cstring) -> string.h (C)

:)

ssharish

ssharish2005 62 Posting Whiz in Training
GROUP *current = NULL;

You have declared this current pointer and you havnt allocated memory for it and again in the groupcon function you are trying to derefrence the null pointer which is an undefined behavior.

Allocate memory in the main and then tru current to the groupcon function. And do the same for all.

And C donst support bool data type. Use macros instead.

ssharish

ssharish2005 62 Posting Whiz in Training

Try download firefox and see if your internet works fine there. Just wanted to make sure that if port 80 is blocked on just IE or on your whole machine. Try it with the different browser.

ssharish

ssharish2005 62 Posting Whiz in Training

Try resetting the IE and see what happenes. How about your firewall Check for your firewall blocking port 80???

ssharish

ssharish2005 62 Posting Whiz in Training

Ok, try deleting your cookies and files. hopefully you should get you internet connection back again. This happenes quite often if you dont clear them for very long time.

Tools->Internet Option->Delete button-> <click> Delete cookies 
Tools->Internet Option->Delete button-> <click> Delete history

Close down all your internet explore and then open up a new one and then try accessing the internet.

ssharish

ssharish2005 62 Posting Whiz in Training

only static and global variables are set to 0 by default.

ssharish.

ssharish2005 62 Posting Whiz in Training

This post refered to my first post which i did on this thread. I posted a code which wasn't compiled. But here is the proper working code.

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>

typedef struct
{
     int *array;
} MODEL;

int main()
{
    MODEL *node;
    int index;
    
    srand( time(0) );
    
    if( ( node = malloc( sizeof( MODEL ) ) ) == NULL )
    {
        perror("malloc");
        return 1;
    }
    else
    {
        printf("1. Node creation successful\n");
        
        if( ( node->array = malloc( sizeof( int ) * 10 ) ) == NULL )
        {
            perror("malloc-array");
            return 1;
        }
        else
        {
            printf("2. Node-array creation successfull\n");
            
            for( index = 0; index < 10; index++ )
                 node->array[index] = rand() % 10;
            
            printf("3. Node-array is filled with random values \n");
            
            printf("4. Print node-array\n");
            
            for( index = 0; index < 10; index++ )
                 printf("%d\t", node->array[index] );
            
            free( node->array );
            printf("5. Node-array is freed\n");
        }
        
        free( node );
        printf("6. node is freed\n");
    }
    
    getchar();
    return 0;
}

/* my output
1. Node creation successful
2. Node-array creation successfull
3. Node-array is filled with random values
4. Print node-array
9       4       9       8       0       4       1       4       9       9
5. Node-array is freed
6. node is freed
*/

ssharish

ssharish2005 62 Posting Whiz in Training

Here is sample code, which demonstrates on how to get a the ASCII code for the entered char.

#include <stdio.h>

#define TRUE      1

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

int main()
{
    unsigned int ch;
    
    while( TRUE )
    {
        printf("\nsingle char please - " ); 
        ch = getchar();
        clear_buffer();
           
        printf("%c - %d", ch, ch );
    } 
}    

/* my output
single char please - a
a - 97
single char please - s
s - 115
single char please - d
d - 100
single char please -
*/

NOTE: This is limitedto quite a lot of stuff. You coud place some error checking to make it more perfect.

And you can always find a ascii char chart on the net. Here is link for one which is found ASCII.

ssharish

ssharish2005 62 Posting Whiz in Training
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>

typedef struct
{ 
    int *array; 
} MODEL;

int main()
{  
   MODEL *node;
   
   node = malloc( 10 * sizeof( MODEL ) ) ;  /* I have node[10] */
       
   node->array = malloc( 100 * sizeof(int) ) ; /*in array, it includes 100 values*/

   /* problem is here:
      if I set node->array: warning: assignment makes integer from pointer without a cast

      if I set node.array: error: request for member ‘array' in something not a structure or union
      What do they mean? 
   */
   
   free( node->array );
   printf("5. Node-array is freed\n");
       
   free( node );
   printf("6. node is freed\n");
   
   getchar();
   return 0;
}

/* my output
[ccccccc@outcast ~/CWork]$ ./a.out 
5. Node-array is freed
6. node is freed
*/

>if I set node->array: warning: assignment makes integer from pointer without a cast
Before, I answer this question, what compiler are you using. It looks like that your using a very old compiler. Well, its telling you to type cast the return type of the malloc. Which it shouldn't. Cos the malloc returned void * which is a generic pointer which get types cast internally. And its not a good programming pratice to type cast the malloc.

The always make sure that you check the return value of malloc. That is MUST.

>if I set node.array: error: request for member ‘array' in something not a structure or union
What this is saying is that, the struct MODEL donst has a data member called array. Well, …

ssharish2005 62 Posting Whiz in Training

Enjoy your stay with our codeeeey world. Warm welcomeing you !!! :)

ssharish

ssharish2005 62 Posting Whiz in Training
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>

typedef struct
{
     int *array;
} MODEL;

int main()
{
    MODEL *node;
    int index;
    
    srand( time(0) );
    
    if( ( node = malloc( sizeof( MODEL ) ) ) == NULL )
    {
        perror("malloc");
        return 1;
    }
    else
    {
        printd("1. Node creation successful\n");
        
        if( ( node->array = malloc( sizeof( int ) * 10 ) ) == NULL )
        {
            perror("malloc-array");
            return 1;
        }
        else
        {
            printf("2. Node-array creation successfull\n");
            
            for( index = 0; index < 10; index++ )
                 node->array[index] = rand() % 10;
            
            printf("3. Node-array is filled with random values \n");
            
            printf("4. Print node-array\n");
            
            for( index = 0; index < 10; index++ )
                 printf("%d\t", node->array[index] );
            
            free( node->array );
            printf("5. Node-array is freed\n");
        }
        
        free( node );
        printf("6. node is freed\n");
    }
    
    getchar();
    return 0;
}

This is just a sample code, please not i dint compile this code. I did my level best. Since my computer is totally froze, I couldn't compile. Hope that shows and idea on how to allocate memory for your structure pointer and more importantly you will have to free them.

ssharish.

ssharish2005 62 Posting Whiz in Training

People, can I please request this is not the place to have such a sort of conversation. Comments are accepted but it should be something relevant to OP question. <Kindly>

ssharish

ssharish2005 62 Posting Whiz in Training

You could use Tcl/Tk as well.

ssharish

ssharish2005 62 Posting Whiz in Training

For me the code works fine, with some minor changes in it. But the code it self is working ok except the integer size. Since you are using turbo C compile which is a 16 bit compiler, the integer size is smaller than ity should be, and that the reason why it works on mine. I would really suggest you to change your compile. Turbo C compiler are no more supported expect they are used in embedded programming thats it.

You need to look in to few more things, you need to read the right variables. shouldn't that scanf function call should lile this way

scanf("%d %d %f", &p, &n, &r);

ssharish

ssharish2005 62 Posting Whiz in Training

ohhh man, it is so difficult to go through your code man. It need to really concentrate on how to indent your code. Give some spacing between instruction and it so compack. And your comments, just makes the code really hard to read.

Do some work on it, i will have look at it. Without that it just not worth me wasting time on it.

ssharish

ssharish2005 62 Posting Whiz in Training

well, this question donst even make any sense, how will we know what IP and the port address you URL uses. when you enter your URL that get resolved y your DNS. If you are looking for the IP address ofthta url, try pinging to that url you will get the IP address. Apart from that port and stuff you should be know. The proxy server details in within your network and we dont know how you have implemeneted your network and no way we could gie you any IP or the details of the proxy server on your network, unless you can give us some more infromation. If you are working on a company or something ask you help desk people theyu might be knowing where the proxy server is and its complete details may be then you can bypass it.

ssharish

ssharish2005 62 Posting Whiz in Training

It would be more helpful if you could specify on what platform and compiler you are using??

ssharish

ssharish2005 62 Posting Whiz in Training

The easy was undersatnding the function is, by think of something like this well. If you have huge lot of code in main, then its a vewry bad programming practice. It is very important that we think before we code it.

As said before, if you a huge main function, that need to be broken down into several groups. And each group of statments will be indentifies through an name indentifer and the each group will be called with some input and function return some outputs.

Like make things clear, consider the following example

#include <stdio.h>

int sum( int, int);

int main()
{
    printf("The sum is - %d\n", sum( 1, 2) );
    
    getchar();
    return 0;

}

int sum(int a, int b)
{
    return (a+b);
}

/* my output

*/

As you can see, the ,first thing you need to do when you work on function is to declare a function prototype where you are making aware the compiler, that somewhere in the future the function sum wil defined and it will used. But make sure that you call the function after it has been declared. Otherwise you will get a error thrown up. And you can also see the how i'am calling the function with some parameter. Parameters or argumnts are something like an input to those function. I my case it integers. It takes those two ints and sums them and retruns them.

Hope that shold roughly should have given you an idea on what …

ssharish2005 62 Posting Whiz in Training

champnim, I suspect the problem might be when you free the node which wanted to delete. Perhaps, the memory leak. Do you know the abc char ptr which you have in your node, that needds to be freed as well, before you free temp!!!

ssharish

ssharish2005 62 Posting Whiz in Training

hey by checking above posts, it reminds me of a concept in C, default arguments!.

I am not sure is there any concept of default arguments?

Thanks

Luckychap, C donst support default arguments. Its only on C++. Well as far as i know. I am pretty sure about it through.

ssharish

ssharish2005 62 Posting Whiz in Training

ohh nelledawg, where did you get the code from. It donst look like that you wrote the code. You need to look into some basic before you program anything like this. You are usinfg some advance pointer types which you need to under stand. Let me should a simple example on how to send arguments. Look at the following code. And arguments is something which you send it a function. These values will then we used in the function for it own processing. So might have been decided for that function does and you should be knowing needed to be sending. So for example

int sun( int a, int b);

The above ius function which takes two integer arguments a & b. Now i know that function takes two integer argument and it works on that two argument. So when I call that function i call it through this way

sum(1, 2);

or 

int a = 10;
int b = 20;

sum(a, b);

Now sit down and look at your code and see what arguments should be sent to the total_sales function.

ssharish

jephthah commented: good call. I think you're right. he didnt write this code, did he? +4