dkalita 110 Posting Pro in Training

Hello All,

how can I create a member function for a class that is reading from a txt file, which is reading computer network addresses and names for the addresses.

I was guessing they need to be string and 4 ints data type.

Example of data.txt file input
111.22.3.3 "green
111.22.44.4 " purple"

also with the option to read 100 addresses

u better use two strings: 1 for the IP , 1 for the name. Thats enough. It will consume less memory as by int and will be easy for further use in methods like socket(), connect() etc wherever required.

dkalita 110 Posting Pro in Training

1> u are doing

fwrite(p,(size*sizeof(p)),size,fp);

which tries to write the whole things together. Better try the following in the file for writting

for(i=0;i<size;i++)
        {
                p[i]=read_rec();
                fwrite(&p[i], sizeof(product), 1, fp);
        }

and hence u wont need the p[] array u can do

product p;
//other code
for(i=0;i<size;i++)
        {
                p=read_rec();
                fwrite(&p, sizeof(product), 1, fp);
        }

test it and inform me..........

2> use CODE tag to embed codes

3> try to define struct like

typedef struct
{
      //members
} product;

That is a good practice.

4> u are writting

fseek(fp,(i*sizeof(p[i])),SEEK_SET);

u should write

fseek(fp, i*sizeof(product), SEEK_SET);

these are good programming practice

dkalita 110 Posting Pro in Training

your problem is here:

if (i = -1)

the condition is always true
try using

if (i == -1)

also see

for (int i = 0; i <= positions.size(); i++) 
{
         if (i = -1) //considering it as (i==-1)
         {
               return true;
         }
         return false;
}

u have initialized i to 0 and did i++ so when will it become ==-1.
It will always return false in the first iteration itself.

dkalita 110 Posting Pro in Training

u have to add a default constructor in the class to continue with your code. Default constructor is created by default if u don't declare any constructor but if u declare some constructor then its not done.

add the following in the Employee class

Employee(){}

dkalita 110 Posting Pro in Training

check the following part of your program in the GetLine() method.

for( i=0;(c=getchar())!='\n';i++) 
{
        SzBuff[i]=c;
        if(c==EOF)  return -1;
}

when u reach EOF u have not terminated your string with '\0'
try

for( i=0;(c=getchar())!='\n';i++) 
{
        SzBuff[i]=c;
        if(c==EOF)
        {
               SzBuff[i] = 0;// newly added
               return -1;
        }
}

the above may be a reason...............try

dkalita 110 Posting Pro in Training

its ok.
Try to use makefile tool for compilation.
Also there is another tool called Imakefile which generates a makefile for u. U can explore those stuff.......have a nice time..... :)

dkalita 110 Posting Pro in Training

Hi,

I am a total newbie when it comes to makefiles and now I'm in a need of one.

I have a directory structure as follows:

Project_root/Makefile
Project_root/src/
Project_root/src/widgets/
Project_root/include/
Project_root/include/widgets/

Each directory contains multiple source/header files.

I need to build a shared library out of this directory and perhaps install the include directory to /usr/include/libname/ and libname.so to /usr/lib/.

Please help me!

Best regards,
zEeLi

Hi,
Makefile is a tool to create process modules and to link them to get the main executable.
I think u will have to write some scripts to achieve what u r saying.
Anyways I am also new to makefile. :)

dkalita 110 Posting Pro in Training

Please can somebody explain to me whether sometimes the strrev function fails or not.
I was giving an assignment to write an application that can detect whether an entered word from the keyboard is a palindrome or not.
After accepting the string and tried to use the function from the string.h.

1> i have never seen strrev() in string.h. May be it is there in some compiler other than i have used.

2> if its there there and is a library function then there is seldom chance that it will fail. Try to get its manual and read.
It would be better if u recheck your code or write your own strrev() which servs your purpose.

dkalita 110 Posting Pro in Training

this is the program where i input struct records...

#include<stdio.h>
#include<conio.h>
struct Product
{

end quote.

post your program properly.

dkalita 110 Posting Pro in Training

u have some logical problems

for(int i=0; i<15; i++)
{
        Makers[i]=new char[256];
        Models[i]=new char[256]; //Welcome screen and instructions      
        Greeting(); //Prompt to continue through program    
        while (true)    
        {
              /*your  code*/
        }
       .............
}

look at it properly
u have allocated memory only once and u have written a while loop inside it which continues untill user exits................

dkalita 110 Posting Pro in Training

Hello,

I'm trying to implement a program in C to read and display data from a text file, assign certain values to pre-defined variables and continue reading in the data.

And example format of the data file is:
---------------------------------------------------------------------------------------------
*** General Comments
*** ....
***...
....
5 125 3
.6167 8.2837 7.4813 4.9291 .4125
......and so on.
---------------------------------------------------------------------------------------------

The asteriks and comments are to be ignored by the program. The first three numbers that the program encounters (5, 125, 3) should be assigned to variables m, n and v which can be called later on. The numbers following that is the data that should also be read in and stored possibly as an array. There might be upto 10,000 data values and beyond.

With the help of the C code snippets posted here I was able to construct a rudimentary program (see code snippet, btw comments can be beside asterisks or percentage signs which is why I have it in the code).

#include <stdio.h>

int main ( void )

{
static const char filename[] = "filename";
FILE *file = fopen ( filename, "r");
fpos_t pos;

char rec [ 125 ]; /* somewhere here is the character for comment */
fgest ( rec, 125, file); /* read a rec */
fgetpos (file,  &pos);
fputs (rec, stdout ); /* write the rec */
while  ( (rec[0] =='*' || rec [0] =='%') || (rec[1] == '*' || rec [1] == '%') || rec[2] == …
dkalita 110 Posting Pro in Training

ya...i tried doing that....i accepted array of records in 1 program and tried to access it randomly in other program by opening the file in read mode and using fseek and fread functions....but it is showing some garbage values....so i have a doubt if we can acess struct records randomly like tat??
thanks in advance...

u are going in the exact direction.
U are getting garbage value is may be because u are not reading in the way u wrote to that file.
U have to use fwrite() for writting then only u will get correct values using fread().

typedef struct
{
 /*your data*/
} myStruct;

int index = 3; // e.g.
myStruct *buf;
int sizeOfStruct = sizeof(myStruct);
fseek(fp, sizeOfStruct*index, SEEK_SET);
if(feof(fp))
{
    cout<<"index out of bound";
    exit(1);
}
else
{
     if(fread(buf, sizeOfStruct, 1, fp)==sizeOfStruct)
     {
            /*your struct is in "buf" 
             *access its member using -> operator*/
     }
      else
      {
             /*data not present*/
             exit(1);
       }
}

and for writting u have to write as

myStruct m;
fwrite(&m, sizeOfStruct, 1, fp);
dkalita 110 Posting Pro in Training

No I've just solved the Problem
In fact I was thinking that send() is also blocking call that waits for client to receive sent data .... but then I realized only recv() is blocking but send() is not blocking .... and this concept solved the problem.

@ above Thanks a lot dear .... u helped me a lot too

u r welcome

dkalita 110 Posting Pro in Training

Attached is my code compressed in a zip file. Also any tips or pointers on how to write good code would be helpful since I have been teaching myself this stuff programmer.

Hi,
I have seen your code. I have fixed some bugs in it. U forgot to check whther an element is there or not in the maps. U directly did

this->labelOPMap.find(currentLabel)->second();

in so many places.
I have found one more error in there in the Parser.cpp file.
u have forgt to initialize the OP variable and u were directly accessing it by *OP.
There is still a bug remaining in your code. Its while executing. I have made a makefile for your code. Use it for compiling. It will be much easier. Just type "make".
Please check your code for the execution part. There is still a segmentation fault coming which I left for u to correct.

dkalita 110 Posting Pro in Training

>U dont need to validate them like that.
Actually he needs to. If the user enters any non-numeric character, his program can hang, halt, break or whatever. The worst part is, that the programmer won't be able to display a error message.


>Link
failbit, badbit, goodbit and stuff only makes my code difficult to read and understand.

If at all I am curious about what my user is inputting, I always input it in form of string and just parse it my own way.
I thus get a lot more control over the input I received.

ya agreed.......
its the best practice to take an input as string so that u have more control over what the user inputs, but also i guess "cin" might be intelligent enough to know whether the input is valid or not and if not then i think we can trap it and ask the user to re-enter his input.

dkalita 110 Posting Pro in Training

There's nothing more to realy see..I gave out all the needed info the rest is just printf /scanf bla bla bla..
I just need help with the last line in my post..

when it comes to pointers to pointer it becomes a little difficult to asssume the thing thats why i asked for the whole program so that i can run it and see whats the problem.

thanks

dkalita 110 Posting Pro in Training

I've been checking all these things for last 5 hours but every thing is fine .... thats y I've posted the code above .... please see if I've left any error that i don't know about ....

can u please send me the complete files (both client and server) at
dharmendra.kalita@ge.com

may be i can find out the problem out there

thanks

dkalita 110 Posting Pro in Training

recv() blocks untill it gets something to read from the inputted socket.
If its blocked clearly means that there is no data to be read.
Check your connection both from server side and client. Check whether the server is connected to the particular client or not and also in the client check the connected server (check the port number, is it the same or not).

dkalita 110 Posting Pro in Training

can u post your program or mail it to me so that i can have a look at it to dharmendra.kalita@ge.com

dkalita 110 Posting Pro in Training

what he says is correct.
U r only checking for the root.
yor function should be something like

int isbal(BST_t *root)
{
   if( root )
   {

        hr=height( root -> right);
        hl=height( root -> left );
        if(!((hr - hl) >= -1 && (hr - hl) <= 1))
                 return 0;
        else
                 return (isbal(root->left) && isbal(root->right));
    }
    else
    {
         return 1;
     }
}

and also thoroughly check the condition
"if(!((hr - hl) >= -1 && (hr - hl) <= 1))"

dkalita 110 Posting Pro in Training

use fork() to create a child process and in the child process use execv() to call the background process.
read about fork() and execv() and their usage.

it looks like

int child;
child=fork();

if(child==0)
{
      execv(............);
}
else
{
        /*current process*/
}
Ancient Dragon commented: Good answer :) +36
kvprajapati commented: Excellent! +18
dkalita 110 Posting Pro in Training

Hi -- After lots of searching I cant seem to find an answer (well one that I understand at least..)

I want to make the variables wobstacle, waisle, and wturn ONLY numbers where a user cannot input a letter and break the program. I was thinking of something along the lines of if wobstacle ! isnan then return them back to the beginning...But the syntax is incorrect and doesn't seem as though I can use it this way...any help?

Thanks

#include <iostream.h>
#include <math.h>
int main()
{
    double wobstacle,   //Width of obstacle
           waisle,      //Width of aisle
           wturn;       //Width of turn
    bool flag;         
         
//Calculate if the turn meets US
flag=true;
   cout << endl << "Please enter the width of the OBSTACLE, AISLE, and "
<< "TURN in inches. (With spaces inbetween): ";
cin >> wobstacle >> waisle >> wturn;

while ( flag == true )
{
//Check for not a number:
if ( wobstacle ! nan && waisle ! nan && wturn ! nan )
              {
                     flag=false;
              }
   else
        cout<< endl << "Please enter a number";
        cin >> wobstacle >> waisle >> wturn;
        flag=true;
      
}     

    if(wobstacle >= 48 && waisle >= 36 && wturn >= 36
                 || wobstacle < 48 && waisle >= 42 && wturn >= 48)
    {
                 cout << "The design specifications meet the UFAS requirements";
    }
    
    else 
         cout << "The design specifications do not meet the UFAS requirements";

system("pause");
return 0;    
}

C++ doesn't support such syntaxes

if ( wobstacle ! nan && waisle ! nan && …
dkalita 110 Posting Pro in Training

How to create classes & object?

First read some book on C++

dkalita 110 Posting Pro in Training

what do u mean by that ?
If u want to randomly access some struct records u can make an array of that struct and proceed........

dkalita 110 Posting Pro in Training

how to make a program that will ignore the highest value and the lowest value, but will get the average of the remaining values..

for example: there are 6 inputted grades, then the 4 middle values should get their average.. and will ignore the highest and lowest..?

:)

write a loop that searches for the highest n lowest value.
Deduct them from the total of all.
Now divide that by total grades - 2.

dkalita 110 Posting Pro in Training

I have been posting a bit about my current side project, a scripting language interpreter. I have gotten past my getline error I talked about in a previous post and am now trying to get the results from the script. I created a map of all the labels in the script with a list of every operation that happens under the list. like this map<string, list<Operation *>>. When ever I try to access the list at a given key I am returned with a bad access error. I try to access the list in the map like this

Operation *currentOP;
    std::list<Operation *> *currentLst;
 
    std::map<std::string,std::list<Operation *> >::iterator labelPtr;
    
    labelPtr = this->labelOPMap.find(currentLabel);
    *currentLst = labelPtr->second; // Problem Here

This is how I am pushing the list onto the map

if(this->hasLabel(programLine)) {
    // push the label and OPlst onto the map
    labelOPMap[label] = *OPlst;
                      
    // Get the new label
    label = this->getLabel(this->positionOfChar('[',programLine),programLine);
                    
    if(!this->labelExist(label)) {
        // Clip the label off the string
        programLine = programLine.substr(this->positionOfChar(']',programLine)+1);
                        
        // Create a new Operation List
        OPlst = new std::list<Operation *>;
    }
}

// Parse the current line of the document and return an operation object
OP = this->ProcessLine(programLine);
                
// push the Operation onto the list
OPlst->push_back(OP);

Does anyone know why I would be getting an bad access error. I am not the best with pointers either.

can u post the complete program so that i can debug it in my machine

dkalita 110 Posting Pro in Training

Hi:

I am trying to create a loop for a code. My loop is supposed to find all the combinations using the numbers 1 and 0 depending on the length of my string. For example if I set up my string to be 3 then the program should give me:
000, 001, 010, 100, 011, 101, 110, 111.
After this the code will use my code to calculate the maximum amount of binary numbers for each string. I have completed the second part, the problem I am having is setting up the loop to give me all the possible combinations. Also the problem is that I need to find the combination up to a string of 32 numbers. I can give you what code I have but I am not sure if that will help, I am just looking for input or ideas of how to set up the loop. Thanks for any comments. An of course I am not looking for you to give me a code, because I need to learn to do it, I am just looking for starting points.

Thanks

G.

if its for 1 and 0 then there is a very simple solution to it. Its as follows:

say your input is 3
the output should be
000, 001, 010, 011, 100, 101, 110, 111
which is actually
0,1,2,3,4,5,6,7 in decimal.
similarly if your input is 4
the outputs will be binary of
0,1,2,.....15 i.e. …

dkalita 110 Posting Pro in Training

I am having problems with traversing a parce tree.
I need to do an in order traversal recursively.

Here's the class's private section...

template <class data>
class BinaryTree
{
	private:
		struct tNode
		{
			data info;
			tNode *left;
			tNode *right;
		};

		tNode *root;
	
	public:
};

I'll be calling inOrderTraversal() from main so I'll need the ability to pass it a tNode pointer, but the tNode struct has to be in the private section of the class. How can I do this? However, this is for a project and I don't want the answer. Just hints please! Thanks! (I have a little integrity)

P.S. if you need more info let me know

when u are writting a class try to make it very simple to the user, i.e. dont let the user give a node as an input because in that case the user needs to know what is a node and how is that represented.
the protorype for yuor traverse function should be like

void traverseInOrder();

to achieve this write the above as a public function and write a private function :

void traverseInorder(tNode* t);

call this function from the public function giving the root as input.

dkalita 110 Posting Pro in Training

Take a look at Office Automation Using Visual C++

hey but i am working in linux shell and i want to write c++ program in there only.
Could u plz help in that.
I mean i wanted to know the representation of a doc file(byte format). Rest i can handle if i get the representation.

thanks in advance

dkalita 110 Posting Pro in Training

hi there i'm new to this and I have a problem with dreamweaver and don't know who to ask.
when I try to view my pages with hitting F12 it keeps saying that I have a broken link and a DNS error.
can you point me in the right direction?
Thank you in advance
Robert

hey but this is a C++ forum............

dkalita 110 Posting Pro in Training

thx niek_e, but is there any other way how i to make this with a single line without to use much variables ? Idea is to pick one of these two chars A or B.

Like

char L = random(from char A, or char B);

u can use the function that i gave as

char x = random('A', 'B');

just change its prototype to

char random(char a, char b);

i hope thats simple enough. i guess thats simplest way to do it.

dkalita 110 Posting Pro in Training

so if 0 is randoms starting number, you add 15 so... 15 is the minimum number

offcourse..........

u can manipulate the random number in whatever way u want it.

dkalita 110 Posting Pro in Training

go through the program. U wil know where to modify.

dkalita 110 Posting Pro in Training

if random is used like random(high number)
why not do random(number)+15

sorry but i didn't get your question. Can u put some light on what u wanted to know.

dkalita 110 Posting Pro in Training

after line 1:
....... '-'
.... ' ' 'g'
after line 2:
...... '-'
... '-' 'g'

after line 3: (correction in here)
............ '-'
. .....'-' ..... 'g'
..........'*'

after line 4:
................ '-'
............ '-' .... 'g'
....... 'e' ... '*'

after line 5:
................ '-'
............ '-' .... 'g'
....... 'e' ... '*'
here it wil fail because of your logic. wen u didn't match the matching element u are always going left and as u can see if u traverse left on getting a mismatch u wil never reach to '*'. Hence this insertion wil fail.

after line 6:
same as above

after line 7:
the symbol '+' is not there hence u wont b able to insert.
afetr line 8:
same as above.

I would suggest u to correct your logic for insertion. u first clarify where u want to insert a new element and what parameters u want for that.

dkalita 110 Posting Pro in Training

[IMG]http://c.uploadanh.com/upload/1/65/0.472257001253785827.jpg[/IMG]

ok i have seen that.
I am looking at your program.
i wil let u know about it.........

dkalita 110 Posting Pro in Training

int T[1001][4001];
needs a huge memory that is equeal to

1001 * 4001 * 4 [sizeof(int) is 4 in linux]
that equeals to

4,000,000 * 4 byte approx
= 16,000,000 byte
= 16,000 KB (approx)
= 16 MB (approx)

due to this size only your system is giving a segmentation fault.

try your program with simply one line

int main()
{
int T[1001][4001];
return 0;
}

it should give a seg fault


if you are doing computation with numbers which takes atmost two byte u can use the "short" data type instead. It should then work fine.

thanks
hope thats of some help

dkalita 110 Posting Pro in Training

or u can do it as

int random(int a, int b)
{
      srand(time(NULL));
   
      int r = rand()%2;

      if(r==0)
            return a;
      else
            return b;
}
dkalita 110 Posting Pro in Training

yes u can declare such function.

But i would suggest u to declare your node as


struct node{
struct grocery* list;
struct node *next;
};

u can allocate memory to it dynamically as

node x;
x.list = (struct grocery *)malloc(5*sizeof(struct grocery));

and u can access them as
*(x.list) ( equiv to x.list[0])
*(x.list + 1) ( equiv to x.list[1])
etc.......

and u can change the syntax of your function as

struct grocery* get_data(struct node n)
{
}
dkalita 110 Posting Pro in Training

i think u should read the C syntaxes for arithmetic operation first.
Thats not a way to do arithmatic operations in C.
U will find them in any book on C.

dkalita 110 Posting Pro in Training

hi
I think your insertion logic is not correct.
While inserting u are checking the _sysMatch symbol to be same.
If the symbol match and particular side(left/right) is not null u are recursively calling the insert function with the same _sysMatch sysmbol for checking, but then that particular symbol wont be there and there will be some other symbols so from now your condition for normal insertion (root->sym==_symMatch)&&(root->left==NULL)will fail because the symbol in root->sym is different now.

let me clarify using your code itself

insertRight(root, '-', 'g');
 insertLeft(root, '-', '-');
 insertRight(root, '-', '*');
 insertLeft(root, '-', 'e');
 insertRight(root, '*', '+');
 insertLeft(root , '*', '/');
 insertLeft(root , '+', 'c');
 insertRight(root, '+', 'd');

after line 1:
....... '-'
.... ' ' 'g'
after line 2:
...... '-'
... '-' 'g'
after line 3:
.... '-'
. '-' ... 'g'
i guess at this point u should get yoyr error message:
"May be u wrong somewhere, try check your code"
This will be clear if u do a dry run of your program in paper.
and your symbol '*' should not get inserted to the tree.

after line 4:
................ '-'
............ '-' .... 'g'
......... 'e'

after line 5:
................ '-'
............ '-' .... 'g'
......... 'e'

[becoz it wont find the symbol '*']

after line 6:
................ '-'
............ '-' ... 'g'

dkalita 110 Posting Pro in Training

look at the following part of code that u have written.......

meter=km/km_per_meter;
cm=meter/meter_per_cm;
inches=cm/cm_per_inches;
feet=inches_per_feet;

u have never initialized the values in the RHS of the statements. e.g.

meter = km/km_per_meter;

here km = 0
km_per_meter = 1000
and (0/1000) = 0
hence when u r trying to print 'meter' u are getting a zero.

This is programming and the statements will be executed in the sequence they appear.

the mistake u did is the following

printf("Enter distance of city 1 in Km: ");
scanf("%d",&inches);

u should have written

printf("Enter distance of city 1 in Km: ");
scanf("%d",&km);

another mistake that u did is in the following line

feet=inches_per_feet;

it should have been

feet=inches/inches_per_feet;

hope that helps

dkalita 110 Posting Pro in Training

u first try the conversion of one form to another first.
After u have tested all of them in individual programs u can try to integrate them............

dkalita 110 Posting Pro in Training

u can write a display function which displays all the values present in the current buffer e.g.

void displayBuffer()
{
      //code to display the contents of the valid buffer//
      //i.e. from head to tail...//
}

u can use this function after any buffer operation such as requestNextBuffer(...) etc.

dkalita 110 Posting Pro in Training

@dkalita,

We do not freely give out code on these forums unless the poster shows some effort. Since you are a "newbie", you need to read this:

http://www.daniweb.com/forums/announcement118-2.html

hey, sorry for that. Actually i am new to this forum and dont know the rules. I will keep this in mind from now.

dkalita 110 Posting Pro in Training

i would also like u to read the strtok() manual first. If u are working in linux just type : man strtok
another thing is that u are trying to strore an array of string to an array of character. u have to declare the array to store the words

char* words[100];

u can now store address of 100 words in the "words" array.

hope that helps a bit...................good luck

dkalita 110 Posting Pro in Training

Using \x I can specify hexadecimal numbers in strings in C, but if I put \x00 then it interprets it as an instruction to terminate the string. As a result I can't express a hexadecimal number with 00 in it using a string! Is there some way around this?

no u cant do that. But if u want to contain that in a string u can try by declaring a
char *str;
variavle and store whatever u want, say
*(str+4) = 0;
and then u can proceed with *(str+5)='a' etc. But if u do this u wont be able to apply any inbuilt functions available in string.h since it will take the 0 as string termination mark. U have to write ur own functions to achieve whatever u want. the only thing extra u will need to do is to keep a length variable along with that or if u use c++ u can write your own string class such that

class MyString
{
char *str;
int length;
public:
MyString();
int length();
....
...//etc....
}

dkalita 110 Posting Pro in Training

program needed

Hi
please find the code below. i have tested the program in linux. it might give some minor error in turbo-c but i hope u can correct those.

#include<stdio.h>

void drawPascalTriangle(int rows);
void getRow(int *prevRow, int prevRowSize, int *row);
void copyRow(int *prevRow, int *row, int rowSize);
void dispRow(int *row, int rowSize, int rows);

int main()
{
	int rows;
	printf("Enter no. of rows:");
	scanf("%d", &rows);
	
	drawPascalTriangle(rows);
	return 0;
}

void drawPascalTriangle(int rows)
{
	int prevRow[50];
	int row[50];
	int prevRowSize = 0;
	int rowSize = 0;
	int i;
	for(i=0;i<rows;i++)
	{
		getRow(prevRow, i, row);
		dispRow(row, i+1, rows);
		printf("\n");
		copyRow(prevRow, row, i+1);
	}
}

void getRow(int *prevRow, int prevRowSize, int *row)
{
	int i;
	for(i=0;i<prevRowSize;i++)
	{
		if(i==0)
		{
			*row = *prevRow;
		}
		else
		{
			*row = *(prevRow) + *(prevRow-1);
		}
		row++;
		prevRow++;
	}
	*row = 1;
}
void copyRow(int *prevRow, int *row, int rowSize)
{
	int i;
	for(i=0;i<rowSize;i++)
	{
		*prevRow = *row;
		prevRow++;
		row++;
	}
}
void dispRow(int *row, int rowSize, int rows)
{
	int i;
	for(i=0;i<rows-rowSize;i++)
		printf("    ");
	for(i=0;i<rowSize;i++)
	{
		printf("%4d    ", *row);
		row++;
	}
}
dkalita 110 Posting Pro in Training

I'm trying to find the largest int in an array and then print it out to the screen. Here is what I have so far:

void LargeNumber(int numbers[], int k){
    int len = k;
    int i = 0;
    int big_num = 0;
    for(i=1; i<len; i++) {
        printf("i is: %d\n", i);
        if(numbers[big_num] < numbers[i]){
            big_num = i;
        }
        if(numbers[big_num] >= numbers[i]){
            printf("Still looking for largest number. \n");
        }
    }
    printf("The largest number is: %d\n", numbers[big_num]);

}

What am I doing wrong? I think it's to do with the comparison between big_num and i but I am having a brain fart and can't work through it. Any help/input would be greatly appreciatted!

hi, i have made correction to your code. Please check it

dkalita 110 Posting Pro in Training

Hi
Can anyone help me in extracting all the tables and its contents that are present in a MS word document using c++ or C