Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-16-2008, 01:39 AM
Sephy's Avatar   
Sephy Sephy is offline
Newbie
 
Join Date: May 2008
Posts: 6
Rep Power: 0
Sephy is on a distinguished road
Question Row length changes?

So basically i got to make program where you can add rows, inside those rows numbers and count in each row and all rows pair number sum.

This far im done and everything is working. Now part which don't want work. I need make option to make rows longer or shorter. For example:

row1 contains 1,4,5,2,4
row2 contains 1,2,5

i want make row1 longer and add 6. row1 now will contain 1,4,5,2,6

so here is code i made so far:
Code:
case '3':{
clrscr();
row=0;
printf("\n Which row length you want change?");
flushall();
scanf("%hd",&row);
g=row-1;              //this is for going to row[0] element
elemcount=lengthie[g]; //this count how much elements i got it my row currently
printf("\n%hd.row  length now is %hd\n",g+1,lengthie[g]);
printf("For how much you want change row length??");
scanf("%hd",&change);
if (change=0){printf("Row length not changed");}

if (change<0){ newlenght=vecaisskaits-change;lengthie[g] = (short int) realloc(newlenght, sizeof(short int));}

if (change>0){ newlenght=elemcount+change;
lengthie[g] = (short int) realloc(newlenght, sizeof(short int));
for(q=elemcount;q=lengthie[g];q++){
printf("\n Insert %hd. row %d. element",g+1,q);
flushall();
scanf("%hd",&elements[g][q]);
}
}  */
getch();
break;}
any sugestions?!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-16-2008, 07:46 AM
v0id's Avatar   
v0id v0id is offline
Super Mod
 
Join Date: Apr 2007
Location: Denmark
Posts: 1,880
Last Blog:
CherryPy(thon)
Rep Power: 23
v0id is a name known to allv0id is a name known to allv0id is a name known to allv0id is a name known to allv0id is a name known to allv0id is a name known to all
Send a message via MSN to v0id
Default Re: Row length changes?

In what way doesn't it work?

I've made an example. It shows how to re-allocate some already allocated space.
Code:
int row_size = 5;
int *row = (int *)malloc(sizeof(int) * row_size);

*(row+0) = 1;
*(row+1) = 4;
*(row+2) = 5;
*(row+3) = 2;
*(row+4) = 4;

row_size++;
row = (int *)realloc(row, sizeof(int) * row_size);

// After the re-allocation, we can now fill index five, too
*(row+5) = 6;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating all sequences of 1s and 0s of length 30 gofer General Programming 5 05-25-2008 05:30 AM
Calculating Line Length yellowhamster C and C++ 6 05-06-2008 06:52 AM
[Added] Length file url field rolandd ionFiles 6 04-28-2008 03:16 PM
USB 2 Maximum Cable Length Jaser Computer Hardware 1 11-08-2007 04:09 PM
variable length arrays in C rattlepanos C and C++ 3 05-03-2007 11:35 AM


All times are GMT -5. The time now is 06:27 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads