Home » Language IDEs » C / C++ IDE (CDT) » stack memory full?!? PLEASE REPLY(single variable addition (even single char) causes NULL output)
() 1 Vote
stack memory full?!? PLEASE REPLY [message #736288] |
Thu, 13 October 2011 22:06 |
Jason Messages: 2 Registered: October 2011 |
Junior Member |
|
|
<<<<<<NEW EDIT>>>>>>>>>
Hi, I'm working on a project on a linux machine in a university comp lab(due tomorow!) which is fairly simple, just reading a netlist, but for some reason I am unable to add any more variables in the program. Right now I have the program set up to read the netlist and copy it into a new output file.
The program reads and writes fine, but I cannot add any code to manipulate the data, because as soon as I add a single variable, int or even char it outputs NULL, even without using the variable.
here is the program
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *nlist,*olist;
char *string;
int i,tmp[2], integer;
nlist = fopen("sample1.net","r"); // or "sample2.net" or "sample3.net"
olist = fopen("out1.net","w");
if(nlist == NULL || olist == NULL)
{
puts("Unable to open file");
exit(0);
}
for(i=0;i<=1;i++)
{
fscanf(nlist,"%s %d",string,&integer);
tmp[i] = integer; //sets up tmp[0] as # of nodes and tmp[1] as # of nets
fprintf(olist,"%s %d\n",string,integer);
}
fclose(olist);
int k;
int Cmatrix[tmp[0]][tmp[0]];
printf("Area of Connectivity Matrix= %d\n",sizeof(Cmatrix)/4);
olist = fopen("out1.net","a");
printf("nodes= %d \nnets= %d",tmp[0],tmp[1]);
for(i=0;i<=tmp[1]-1;i++)
{
fscanf(nlist,"%s %d %s",string,&integer,string+3);
fprintf(olist,"\n%s %d %s",string, integer,string+3);
for(k=0;k <=tmp[0];k++)
{
fscanf(nlist,"%d",&integer);
fprintf(olist,"%d ",integer);
}
}
fclose(olist);
fclose(nlist);
return 0;
}
This effectively copies a netlist into a new output, due to a lack of response I had to be creative with variables, because now any new variable be it an int or even char forces all variables to equal zero and outputs
(null) 0
(null) 0
(removing extra variable again creates correct output)
is there something I can do to flush the buffer or something along those lines?
ANY ANY ANY help is appreciated at this point it is near impossible to continue programming without adding additional variables!!
[Updated on: Fri, 14 October 2011 02:39] Report message to a moderator
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 08:02:17 GMT 2024
Powered by FUDForum. Page generated in 0.03345 seconds
|