I tried pointing
int (*p)[10] to a single dimensional array,the compiler was giving a warning,but when I made same kind of pointer to a 2d array,it excuted cleanly without throwing any warning.
...
Type: Posts; User: shruthi
I tried pointing
int (*p)[10] to a single dimensional array,the compiler was giving a warning,but when I made same kind of pointer to a 2d array,it excuted cleanly without throwing any warning.
...
#include<stdio.h>
int main()
{
int arr[3],*q=arr,i;
int (*p)[3]=arr;
for(i=0;i<3;i++)
scanf("%d",(q+i));
for(i=0;i<3;i++)
...
scanf("%d",&a[i][j]); // this is fine
I wanted to know is there any other way to access the array using pointer,other than the way I have mentioned in my program?
isn't int (*p)[10][10];
different from
int (*p)[10];
isn't the first one used to point to a 3D array and the second one used to point to the 2D array or are they both same?
Hi Everyone!
Is there another way to store and access the the 2D array using pointer to a 2D array.
#include<stdio.h>
int main()
{
int a[10][10],i,j,r,c;
int (*p)[10]=a;
Actually the answer was varying from 0.000 to the right answer. So I thought there would be some problem with returning the double value.
Hi everyone! When I take the help of pointers,by keeping the return type of the function as void,the program works fine,but when I try to pass the values to the function and use return type as...
This is great! Thanks :)
ok.Thanks :)
I was just experimenting with using malloc and realloac on how to access and see if it was reading into the new loaction,so took an example of 5 and 8.That's when I realised the number of pointers...
Hi Everyone!
Is there a way to reduce the number of pointers used in this program using malloc itself.
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p,*q,i,*r,*w;
p=(int...
Thanks :) It's working neatly when I added the given code.
Ok,Ive given it a try.
#include#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char *str1[3];
char data[40];
I guess it's just easier to use a 2d char array.
I thought since you can store strings
char *arr[3]={"mon","tuesday","wednesday"};
I thought one could possibly take the user input and it...
I am tryin to use char array of pointer instead of a 2d char array,to reduce the fixed size usage of the 2d array.
#include<stdio.h>
int main()
{
char *days[2]={"mon","tue"};
printf("%s\n",days[0]);
return 0;
}
Where in data mon & tue getting stored?
Instead of initialising in the program I...
Hi Everyone!
I am trying to use array of pointers to store strings and trying to take the input from the user for that I am using fgets,but it's throwing a segmentation fault.what is the right...
Thanks a lot everyone.
When I checked the size of int and char*,it's giving me 4 for both.But when I use char*,no warnings are displayed and displays the output as 8.
How is it that when I use int it throws warning and...
Tried what you written,but's it's giving an answer as 2 instead of the 8.
Hi Everyone!
I have written a code for it,it gives 2 warning messages but still gives the right answer.Can you share better ideas to implement for this concept.
#include<stdio.h>
union size
{...
thanks a lot.
with slight changes made to the program got the output,it wasn't the fault of '\n'.
while(i<25-1)
{
scanf("%c",&c[i]);
if(c[i]=='\n')
break;
i++;
It not terminating when I use '\n'
Hi Everyone!
I am trying to store string input with spaces and the program should stop taking the input while the enter key is pressed.
#include<stdio.h>
int main()
{
char c[25];
...