指向数据类型和数据成员的指针之间的区别

时间:2015-09-27 19:00:32

标签: c pointers

我正在学习C而且我很难理解两个指针之间的区别

double **X;

double** X;

两者都一样吗?

还有一个问题。

我们什么时候实际上使用指针来指向上面**X

之类的指针

1 个答案:

答案 0 :(得分:0)

这两个例子都是一样的。它将//Downloading data asynchronously public class AsyncHttpTask extends AsyncTask<String, Void, Integer> { @Override protected Integer doInBackground(String... params) { Integer result = 0; try { // Create Apache HttpClient HttpClient httpclient = new DefaultHttpClient(); HttpResponse httpResponse = httpclient.execute(new HttpGet(params[0])); int statusCode = httpResponse.getStatusLine().getStatusCode(); // 200 represents HTTP OK if (statusCode == 200) { String response = streamToString(httpResponse.getEntity().getContent()); parseResult(response); result = 1; // Successful } else { result = 0; //"Failed } } catch (Exception e) { Log.d(TAG, e.getLocalizedMessage()); } return result; } @Override protected void onPostExecute(Integer result) { // Download complete. Let us update UI if (result == 1) { mGridAdapter.setGridData(mGridImages); mGridAdapter.notifyDataSetChanged(); } else { Toast.makeText(MainActivity.this, "No Connection found,Check your Connection!", Toast.LENGTH_SHORT).show(); } mProgressBar.setVisibility(View.GONE); } } String streamToString(InputStream stream) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream)); String line; String result = ""; while ((line = bufferedReader.readLine()) != null) { result += line; } // Close stream if (null != stream) { stream.close(); } return result; } /** * Parsing the feed results and get the list * @param result */ private void parseResult(String result) { try { JSONObject response = new JSONObject(result); JSONArray posts = response.optJSONArray("result"); GridImages item; for (int i = 0; i < posts.length(); i++) { JSONObject post = posts.optJSONObject(i); String title = post.optString("name"); String image=post.optString("path"); item = new GridImages(); item.Settitle(title); item.Setimage(image); // JSONArray attachments = post.getJSONArray("attachments"); // if (null != attachments && attachments.length() > 0) { // JSONObject attachment = attachments.getJSONObject(0); // if (attachment != null) // item.Setimage(attachment.getString("url")); //} mGridImages.add(item); } } catch (JSONException e) { e.printStackTrace(); } } 的类型定义为指向double的指针。

数组是一个连续的内存片段,您可以通过指向它的第一个元素来访问它。如果你有一个数组数组,那么它的类型是X

例如,字符串是字符数组,以'\ 0'字节结尾。所以字符串数组的类型为'whatever element type is'**

示例用法非常常见,char**函数,可以声明如下

main()

所以int main(int argc, char** argv) 是一个字符串数组,它们是参数或程序,argv是它的长度。