Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
100% Quality Score
Upvotes Received
1
Posts with Upvotes
1
Upvoting Members
1
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
~7K People Reached
Favorite Forums
Favorite Tags
c x 44

23 Posted Topics

Member Avatar for Cpp_Addict

What i understood from your question is that you are trying to read multiple strings in a single array..Then i think you need to take two dimensional array...see the code below: [code] #include<stdio.h> int main() { char arr[5][20]; int i; for (i=0;i<5;i++) { printf("\n Enter the string :"); fgets(arr[i],20,stdin); } …

Member Avatar for urjapandya
0
2K
Member Avatar for me_ansh

Hi all, I want to find the size of proc file using C....can somebody help!!!!

Member Avatar for MosaicFuneral
0
122
Member Avatar for CoolAtt

Okay....I think, the following prototype might help you... - I made this on Linux and compiled with gcc - 'test.txt' was in the same directory as my '.c' file [code] #include<stdio.h> #include<string.h> int main(void) { char buff[100]; FILE* fp_1; fp_1 = fopen("./test.txt","r"); memset(buff,0,sizeof(buff)); while(1) { if(fgets(buff,100,fp_1)) ; else { printf("\n …

Member Avatar for CoolAtt
0
720
Member Avatar for me_ansh

Hi, I am facing a problem, I am accessing a text file through my C program to fetch some values. The problem is that, i want to check whether the text file is updated before opening it, as i want to save the time of opening the file again if …

Member Avatar for Salem
0
156
Member Avatar for slimjimmer

[code] for(i = 0; i < arraysize; i++) { [B]randno[i] = malloc(10 * sizeof(int)); [/B]// [B]TYPECAST THE OUTPUT OF MALLOC[/B] }arraysize = 100; // number of rows randno = malloc(arraysize * sizeof(int *)); // allocate array of pointers [/code] And one more thing to add, Always typecast the output of …

Member Avatar for Salem
0
227
Member Avatar for me_ansh

The man page of 'sscanf' says: "EOF is also returned if a read error occurs, in which case the error indicator for the stream (see ferror(3)) is set, and errno is set indicate the error" I am confused that what kind of read error may occur if sscanf is reading …

Member Avatar for me_ansh
0
93
Member Avatar for death_oclock

The structure in wave.h is typedef'd as 'WAVE_FILE' and in your analyze.c you are using [code=c] WAV_FILE file; [/code] Don't you think its a typing mistake and should be WAVE_FILE file???

Member Avatar for Aia
0
135
Member Avatar for zoner7

[code=c] int function(char *source) { /* add stuff here Note: do not use a buffer overflow*/ return 0; } void main(){ int x; x=0; if(function("...")) x=1; printf("%d\n",x); } [/code]

Member Avatar for zoner7
0
803
Member Avatar for Logi.

malloc always returns starting address of the memory allocated so may be the line: [code] Queue q = (Queue)malloc(sizeof(Queue)); [/code] could well be replaced by [code] Queue *q = (Queue*)malloc(sizeof(struct Queue)); [/code]

Member Avatar for Logi.
0
185
Member Avatar for encee

Well, i think, this might be a simpler way to solve your problem. I took an array of inetegers to be populated. [code] int main(void) { FILE *fp; char buff[100]; int i = 0; int var[100]; fp = fopen("./test.txt","r"); while(fgets(buff,sizeof(buff),fp) { for(i=0;i<strlen(buff);i++) { if(isdigit(buff[i])) { var[i] = buff[i] - 48; …

Member Avatar for me_ansh
0
1K
Member Avatar for Trendkiller

Ya, there is syntax error as stated in the above post...Also i want to add that even if there is only one expression corresponding to an 'if' or 'else', try using braces, this eliminates the possiblity of any ambiguity or error in future and code becomes managable... if { /*Expression*/ …

Member Avatar for me_ansh
0
329
Member Avatar for me_ansh

Hello every one, I have a confusion regarding arrays and pointers, My question is: "Is array name a pointer (rather a constant pointer)"?? I feel the answer is 'yes' because we can use the de-referencing operator(*) with the array name, Also, because array name is a constant pointer so we …

Member Avatar for Narue
0
264
Member Avatar for asharrajpoot

I have written some rough code, please modify according to your requirement: 1) For pattern A B C D E F G F E D C B A A B C D E F __F E D C B A A B C D E _____E D C B A …

Member Avatar for me_ansh
0
188
Member Avatar for boomtoom

Firstly, saying things like 'why doesnt it work for me' does not help us understanding your problem, please specify what exactly is the problem..

Member Avatar for me_ansh
0
123
Member Avatar for titosd

"[B]When arrays are declared as function parameters then they are treated as pointers and not arrays[/B]"....I think this would help you out...

Member Avatar for me_ansh
0
192
Member Avatar for mohan_198505

One possible reason can be that 'func.c' is not in the same directory/folder as 'myheader.h' and if this is the case then either you can put the 'myheader.h' in the same directory/folder as 'func.c' [B]OR[/B] You can put the 'myheader.h' in some standard path where your turbo c compiler searches …

Member Avatar for ajay.krish123
0
163
Member Avatar for c_Newbie

[code] #include<stdio.h> int main(void) { FILE* fd; char buff[100]; fd = fopen("./test.txt","r"); fgets(buff,sizeof(buff),fd); //here the line from file comes to char array buff printf("\n%s\n",buff); return 0; } [/code]

Member Avatar for c_Newbie
0
112
Member Avatar for Lilal

What exactly are you trying to do here?? [code] char CountMin[1]; CountMin[0] = "8"; [/code] storing string in a charachter??

Member Avatar for Lilal
0
118
Member Avatar for Emma1

Also fgets() takes 'number of bytes to be copied' as an argument, which is a very good practice as it never lets you in problems like 'buffer overflows'...Use of gets() is generally discouraged.. For further info: man fgets (if you are on linux)

Member Avatar for Ancient Dragon
0
111
Member Avatar for prashanth s j

As per the data provided by you, everything seems fine so please post the complete code in flow....

Member Avatar for me_ansh
0
101
Member Avatar for RenFromPenn

[code] while (fscanf(inFile, "%s", str) !=EOF) /*Reads and displays the file*/ fclose(inFile); //[B]Why are you closing the file in mid of everything[/B] for( i = 0; str[ i ]; i++) str[ i ] = toupper( str[ i ] ); printf("%s\n", str); /* uppercase string */ return 0; } [/code] if …

Member Avatar for ajay.krish123
0
140
Member Avatar for arunprabhu.1

An addition, Once you've got the 1st or 3rd line using fgets() in a buffer, just go the position where the integer value starts and read the value using sscanf() with %d format specifier.. Hope this helps...

Member Avatar for me_ansh
0
82
Member Avatar for kishendra

Ha ha ha.... That reminds me of my school days when i used to think "I wish some angel does my home work"....We are not here to solve assignments, are we?

Member Avatar for me_ansh
0
158

The End.