473,394 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

pointer on field. mitola

17
C language:
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {int nak[50];int *i;
  7.     srand(time(NULL));
  8.     for(i=&nak[0];i<&nak[50];i++)
  9.     {
  10.     nak[i]=rand()%50+450;
  11.     }
  12.     system("pause");
  13.     return 0;
  14. }

nak[i]=rand()%50+450; here is something wrong but how can i use i like counter in nak[50] that table.
Oct 14 '07 #1
1 1088
weaknessforcats
9,208 Expert Mod 8TB
{int nak[50];int *i;
srand(time(NULL));
for(i=&nak[0];i<&nak[50];i++)
{
nak[i]=rand()%50+450;
}
system("pause");
return 0;
}
Here i should be an integer rather than a pointer to an integer. Your loop needs to run from 0 to 49:
Expand|Select|Wrap|Line Numbers
  1. {int nak[50];int i;
  2. srand(time(NULL));
  3. for(i=0;i< 50;i++)
  4. {
  5. nak[i]=rand()%50+450;
  6. }
  7. system("pause");
  8. return 0;
  9. }
  10.  
Oct 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: jennifer johnson | last post by:
Hello All, I appreciate anyone's assistance. I wanted to validate user customizable field values so I changed my JSP page so that the form action would post existing form - action=<%=...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
12
by: Alexander Stippler | last post by:
Hello, I've got a quite simple question. I want to have something like int main() { double array = {{1,2,3}, {4,5,6}, {7,8,9}}; double **field; field = array;
1
by: r.devaraj | last post by:
Some typo and confusion in previous post (http://groups.google.com/group/comp.lang.c/browse_thread/thread/5e1f7437701250c4/c83fdc9a2d49e9ac?hl=en#c83fdc9a2d49e9ac) made it difficult for me to fetch...
1
by: Jeff | last post by:
I am struggling with the following How do I marshal/access a pointer to an array of strings within a structure Than Jef ----------------------------------------------------------------
6
by: Tim | last post by:
I'm trying to co-erce a __gc array of Byte to a __nogc pointer to char to pass to a native function call in a bit of managed c++ code like this: Byte field __gc = dynamic_cast<Byte...
23
by: Eric J.Hu | last post by:
Hi, I have following code, want do pointer convert. It always complain: vcnvt.c: In function `main': vcnvt.c:20: warning: dereferencing `void *' pointer vcnvt.c:20: request for member `key'...
2
by: mark.e.nelson | last post by:
Hi, I am trying to pass a pointer to a struct to a function that uses the data in the struct, and also happens to use ncurses. I always get a segmentation violation when the program exits. I...
12
by: gcary | last post by:
I am having trouble figuring out how to declare a pointer to an array of structures and initializing the pointer with a value. I've looked at older posts in this group, and tried a solution that...
30
by: Jess | last post by:
Hello, I tried a program as follows: include<iostream> using namespace std; class A{ public:
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.