以下程序不调用用户定义的函数 [英] The below program is not calling the user defined function

查看:130
本文介绍了以下程序不调用用户定义的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<iostream>
#include<string.h>
#include<stdio.h>

using namespace std;
char con(char *str1,char *str2,char *str3);
main()
{
	char str1[50],str2[50],str3[50];
	cin.getline(str1,50);
	cin.getline(str2,50);
	cout<<"Enter after which word the phrase to be concatenated\n";
	cin.getline(str3,50);
	con(str1,str2,str3);
	cout<<str1;
	cout<<endl<<endl;
	system("pause");
}
char con(char *str1,char *str2,char *str3)
{
	char temp[50];
	int l1,l3=0,tl=0,l2,la,ls=la,lg;
	for(l1=0;str1[l1]=str3[0];l1++)
	{
		l1++;l3++;
		while(str1[l1]!=str3[l3],str1[l1],str3[l3])
		{
			l1++;l3++;
		}
	}
	l1++;
	la=l1;
	while(str1[l1])
	{
		str1[l1]=temp[tl];
		l1++;tl++;
	}

	for (l2=0;str2[l2];l2++,la++)
	{
		str1[la]=str2[l2];
	}
	tl=0;
	while (temp[tl])
	{
		str1[la]=temp[tl];
		tl++;la++;
	}
	return *str1;
}





我的尝试:



在str1(字符串)的特定字后连接str2(字符串)



What I have tried:

concatenate str2(string) after a specific word of str1(string)

推荐答案

您应该学习尽快使用调试器。而不是猜测你的代码在做什么,现在是时候看到你的代码执行并确保它完成你期望的。



调试器允许你跟踪执行逐行检查变量,你会看到有一点它会停止你所期望的。

在Visual Studio 2010中掌握调试 - 初学者指南 [ ^ ]

http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html [ ^ ]

https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html [ ^ ]



建议:在你的代码中添加注释有助于检查代码是否符合预期。

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]

Advice: put comments in your code it help to check if code do what you expect.
引用:

以下程序没有调用用户定义的函数

The below program is not calling the user defined function

函数可能被调用,但是没有按预期执行。

The function is probably called, but don't perform as expected.


这篇关于以下程序不调用用户定义的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆